Skip to content

Commit

Permalink
restricting scan
Browse files Browse the repository at this point in the history
  • Loading branch information
git-elliot committed Aug 31, 2023
1 parent a5ab106 commit fe91240
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/host_scan_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:universal_io/io.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
int port = 0;
int hostId = 0;
String myOwnHost = "0.0.0.0";
String interfaceIp = myOwnHost.substring(0, myOwnHost.lastIndexOf('.'));
late ServerSocket server;
Expand All @@ -29,7 +30,11 @@ void main() {
.address; //gives IP address of GHA local machine.
myOwnHost = address;
interfaceIp = address.substring(0, address.lastIndexOf('.'));
debugPrint("own host $myOwnHost and interfaceIp $interfaceIp");
hostId = int.parse(
address.substring(address.lastIndexOf('.') + 1, address.length));

debugPrint(
"own host $myOwnHost and interfaceIp $interfaceIp and $hostId");
}
}
});
Expand All @@ -40,24 +45,23 @@ void main() {
//There should be at least one device pingable in network
HostScannerFlutter.getAllPingableDevices(
interfaceIp,
firstHostId: hostId - 1,
lastHostId: hostId + 1,
),
emits(isA<ActiveHost>()),
);
// own host can be 254, 1 sec per host means timeout atleast 260 secs.
}, timeout: const Timeout(Duration(seconds: 260)));
});

group('Testing Host Scanner emitsThrough', () {
});
test('Running getAllPingableDevices emitsThrough tests', () async {
expectLater(
//Should emit at least our own local machine when pinging all hosts.
HostScannerFlutter.getAllPingableDevices(
interfaceIp,
firstHostId: hostId - 1,
lastHostId: hostId + 1,
),
emitsThrough(ActiveHost(internetAddress: InternetAddress(myOwnHost))),
);
// own host can be 254, 1 sec per host means timeout atleast 260 secs.
}, timeout: const Timeout(Duration(seconds: 260)));
});
});

tearDownAll(() {
Expand Down

0 comments on commit fe91240

Please sign in to comment.