-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #216 from osociety/more-integration-tests
Added test for ping page
- Loading branch information
Showing
14 changed files
with
270 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:vernet/main.dart'; | ||
import 'package:vernet/ui/adaptive/adaptive_list.dart'; | ||
import 'package:vernet/values/keys.dart'; | ||
import 'package:vernet/values/strings.dart'; | ||
|
||
void main() { | ||
group('Dns lookup integration test', () { | ||
testWidgets('tap on the DNS lookup button, verify lookup ended', | ||
(tester) async { | ||
// Load app widget. | ||
await tester.pumpWidget(const MyApp(true)); | ||
await tester.pumpAndSettle(); | ||
|
||
// Verify that there are 4 widgets at homepage | ||
expect(find.bySubtype<AdaptiveListTile>(), findsAtLeastNWidgets(4)); | ||
|
||
// Finds the scan for devices button to tap on. | ||
final lookupButton = find.byKey(WidgetKey.dnsLookupButton.key); | ||
|
||
// Emulate a tap on the button. | ||
await tester.tap(lookupButton); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.text(StringValue.dnsLookupEmptyPlaceholder), findsOneWidget); | ||
|
||
await tester.enterText( | ||
find.byType(TextFormField), | ||
'google.com', | ||
); | ||
await tester.pumpAndSettle(); | ||
|
||
final submitButton = find.byKey(WidgetKey.basePageSubmitButton.key); | ||
await tester.tap(submitButton); | ||
|
||
await tester.pumpAndSettle(const Duration(seconds: 2)); | ||
|
||
expect(find.byType(AdaptiveListTile), findsExactly(3)); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:vernet/main.dart'; | ||
import 'package:vernet/ui/adaptive/adaptive_list.dart'; | ||
import 'package:vernet/values/keys.dart'; | ||
import 'package:vernet/values/strings.dart'; | ||
|
||
void main() { | ||
group('Reverse DNS lookup integration test', () { | ||
testWidgets('tap on the reverse DNS lookup button, verify lookup ended', | ||
(tester) async { | ||
// Load app widget. | ||
await tester.pumpWidget(const MyApp(true)); | ||
await tester.pumpAndSettle(); | ||
|
||
// Verify that there are 4 widgets at homepage | ||
expect(find.bySubtype<AdaptiveListTile>(), findsAtLeastNWidgets(4)); | ||
|
||
// Finds the scan for devices button to tap on. | ||
final reverseDnsLookupButton = | ||
find.byKey(WidgetKey.reverseDnsLookupButton.key); | ||
|
||
// Emulate a tap on the button. | ||
await tester.tap(reverseDnsLookupButton); | ||
await tester.pumpAndSettle(); | ||
|
||
expect( | ||
find.text(StringValue.reverseDnsLookupEmptyPlaceholder), | ||
findsOneWidget, | ||
); | ||
|
||
await tester.enterText( | ||
find.byType(TextFormField), | ||
'172.217.160.142', | ||
); | ||
await tester.pumpAndSettle(); | ||
|
||
final submitButton = find.byKey(WidgetKey.basePageSubmitButton.key); | ||
await tester.tap(submitButton); | ||
|
||
await tester.pumpAndSettle(const Duration(seconds: 2)); | ||
|
||
expect(find.text("maa03s29-in-f14.1e100.net"), findsOne); | ||
}); | ||
}); | ||
} |
47 changes: 47 additions & 0 deletions
47
integration_test/network_troubleshooting_test/ping_test/ping_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:network_tools_flutter/network_tools_flutter.dart'; | ||
import 'package:vernet/main.dart'; | ||
import 'package:vernet/ui/adaptive/adaptive_list.dart'; | ||
import 'package:vernet/values/keys.dart'; | ||
|
||
void main() { | ||
group('Ping integration test', () { | ||
testWidgets('tap on the ping button, verify ping ended', (tester) async { | ||
// Load app widget. | ||
await tester.pumpWidget(const MyApp(true)); | ||
await tester.pumpAndSettle(); | ||
|
||
// Verify that there are 4 widgets at homepage | ||
expect(find.bySubtype<AdaptiveListTile>(), findsAtLeastNWidgets(4)); | ||
|
||
// Finds the scan for devices button to tap on. | ||
final pingButton = find.byKey(WidgetKey.ping.key); | ||
|
||
// Emulate a tap on the button. | ||
await tester.tap(pingButton); | ||
await tester.pumpAndSettle(); | ||
final interface = await NetInterface.localInterface(); | ||
|
||
await tester.enterText( | ||
find.byType(TextFormField), | ||
interface?.ipAddress ?? '192.168.0.1', | ||
); | ||
await tester.pumpAndSettle(); | ||
|
||
final submitButton = find.byKey(WidgetKey.basePageSubmitButton.key); | ||
await tester.tap(submitButton); | ||
|
||
await tester.pumpAndSettle(const Duration(seconds: 5)); | ||
|
||
expect(find.byKey(WidgetKey.pingSummarySent.key), findsOneWidget); | ||
expect(find.byKey(WidgetKey.pingSummaryReceived.key), findsOneWidget); | ||
expect(find.byKey(WidgetKey.pingSummaryTotalTime.key), findsOneWidget); | ||
|
||
expect(find.text('Sent: 5'), findsOneWidget); | ||
expect(find.text('Received : 5'), findsOneWidget); | ||
expect(find.text('Total time: --'), findsOneWidget); | ||
expect(find.byType(AdaptiveListTile), findsAtLeastNWidgets(5)); | ||
}); | ||
}); | ||
} |
84 changes: 84 additions & 0 deletions
84
integration_test/wifi_test/host_scan_and_port_scan_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:network_tools_flutter/network_tools_flutter.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
import 'package:vernet/injection.dart'; | ||
import 'package:vernet/main.dart'; | ||
import 'package:vernet/ui/adaptive/adaptive_list.dart'; | ||
import 'package:vernet/values/globals.dart' as globals; | ||
import 'package:vernet/values/keys.dart'; | ||
|
||
void main() { | ||
globals.testingActive = true; | ||
late ServerSocket server; | ||
int port = 0; | ||
setUpAll(() async { | ||
configureDependencies(Env.test); | ||
final appDocDirectory = await getApplicationDocumentsDirectory(); | ||
await configureNetworkToolsFlutter(appDocDirectory.path); | ||
//open a port in shared way because of portscanner using same, | ||
//if passed false then two hosts come up in search and breaks test. | ||
server = | ||
await ServerSocket.bind(InternetAddress.anyIPv4, port, shared: true); | ||
port = server.port; | ||
debugPrint("Opened port in this machine at $port"); | ||
}); | ||
|
||
group('host scanner end-to-end test', () { | ||
testWidgets('tap on the scan for devices button, verify device found', | ||
(tester) async { | ||
// Load app widget. | ||
await tester.pumpWidget(const MyApp(true)); | ||
await tester.pumpAndSettle(); | ||
|
||
// Verify that there are 4 widgets at homepage | ||
expect(find.bySubtype<AdaptiveListTile>(), findsAtLeastNWidgets(4)); | ||
|
||
// Finds the scan for devices button to tap on. | ||
final devicesButton = find.byKey(WidgetKey.scanForDevicesButton.key); | ||
|
||
// Emulate a tap on the button. | ||
await tester.tap(devicesButton); | ||
await tester.pump(); | ||
expect(find.byType(AdaptiveListTile), findsAny); | ||
await tester.pumpAndSettle(const Duration(seconds: 10)); | ||
await tester.pump(); | ||
expect(find.byType(AdaptiveListTile), findsAtLeast(2)); | ||
final routerIconButton = | ||
find.byKey(WidgetKey.thisDeviceTileIconButton.key); | ||
|
||
await tester.scrollUntilVisible( | ||
routerIconButton, | ||
500.0, | ||
scrollable: find.byType(Scrollable), | ||
); | ||
|
||
expect(routerIconButton, findsOne); | ||
await tester.tap(routerIconButton); | ||
await tester.pumpAndSettle(); | ||
expect(find.byType(AppBar), findsOne); | ||
|
||
final radioButton = find.byKey(WidgetKey.singlePortScanRadioButton.key); | ||
await tester.tap(radioButton); | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.enterText( | ||
find.byKey(WidgetKey.enterPortTextField.key), | ||
port.toString(), | ||
); | ||
await tester.pumpAndSettle(); | ||
|
||
final portScanButton = find.byKey(WidgetKey.portScanButton.key); | ||
await tester.tap(portScanButton); | ||
await tester.pumpAndSettle(); | ||
await tester.pump(); | ||
expect(find.byType(AdaptiveListTile), findsAny); | ||
}); | ||
}); | ||
|
||
tearDownAll(() { | ||
server.close(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'host_scan_and_port_scan_test.dart' as host_scan_and_port_scan; | ||
|
||
void main() { | ||
host_scan_and_port_scan.main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.