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

Merge dev into main #206

Merged
merged 86 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
9494ac3
Added simple integration test for host scanner
git-elliot Nov 9, 2024
7a55394
run integration tests in ci
git-elliot Nov 9, 2024
a49971e
check api 29 first
git-elliot Nov 9, 2024
3d43a48
use only macos
git-elliot Nov 9, 2024
df31025
run test
git-elliot Nov 9, 2024
edd6d03
device added
git-elliot Nov 9, 2024
49b9930
test fixed
git-elliot Nov 9, 2024
09ca016
remove upgrade dep because lock file exists
git-elliot Nov 9, 2024
17a8698
remove upgrade dep because lock file exists
git-elliot Nov 9, 2024
9ba3a32
remove upgrade dep because lock file exists
git-elliot Nov 9, 2024
6875b31
rearrange
git-elliot Nov 9, 2024
4d96120
fixed tests
git-elliot Nov 9, 2024
f62158c
analyzer fixes
git-elliot Nov 9, 2024
c3e42a0
test fixes
git-elliot Nov 9, 2024
ffe8097
verificaiton
git-elliot Nov 9, 2024
aae7783
fix command
git-elliot Nov 9, 2024
c1d7d68
Merge pull request #203 from osociety/integration-tests
git-elliot Nov 9, 2024
9b225bb
Check integration tests are passing or not
git-elliot Nov 9, 2024
800459e
merge
git-elliot Nov 9, 2024
43223cc
added more tests
git-elliot Nov 9, 2024
e51e9e1
fix tests
git-elliot Nov 9, 2024
31916c7
check if test is culprit
git-elliot Nov 9, 2024
b5f80e5
check if test passes now
git-elliot Nov 9, 2024
4fb5383
check return code
git-elliot Nov 9, 2024
dfb4996
tests fucking sucks
git-elliot Nov 9, 2024
6bffd5e
check tests
git-elliot Nov 9, 2024
4d91972
fix
git-elliot Nov 9, 2024
2999382
fix
git-elliot Nov 9, 2024
9517f39
pump and settle
git-elliot Nov 9, 2024
c59f2c9
increased duration
git-elliot Nov 9, 2024
36ed0be
pumpAndSettle causes trouble
git-elliot Nov 9, 2024
8b72b01
pump
git-elliot Nov 9, 2024
cac7385
removed progrees bar
git-elliot Nov 9, 2024
826315d
icon not found
git-elliot Nov 9, 2024
a71673c
added indicator back
git-elliot Nov 9, 2024
6aa4cdd
delay
git-elliot Nov 9, 2024
55154d0
removed indicator
git-elliot Nov 9, 2024
b1be7b4
Merge pull request #204 from osociety/integration-tests
git-elliot Nov 9, 2024
5029e38
Host Scan to Port scan integration flow
git-elliot Nov 10, 2024
6defd64
finished flow
git-elliot Nov 10, 2024
fec932a
Merge branch 'dev' into integration-tests
git-elliot Nov 10, 2024
f102793
Update app_test.dart
git-elliot Nov 10, 2024
9eb1978
opened port
git-elliot Nov 10, 2024
b39f054
comment main branch
git-elliot Nov 10, 2024
97d6269
fix test
git-elliot Nov 10, 2024
80c8496
removed port test
git-elliot Nov 10, 2024
40b3ca3
port scan test
git-elliot Nov 10, 2024
eddb40a
remove circular progress indicator
git-elliot Nov 10, 2024
360bf3a
timeout increase
git-elliot Nov 10, 2024
b48be4c
findsany
git-elliot Nov 10, 2024
fefa93b
debug later
git-elliot Nov 10, 2024
00114bf
fix bloody damn test
git-elliot Nov 10, 2024
7390e20
chck int tests
git-elliot Nov 10, 2024
17a9b2e
add messages
git-elliot Nov 10, 2024
29f5c58
remove indiactor
git-elliot Nov 10, 2024
82be57d
fix tests
git-elliot Nov 10, 2024
5f2e2f2
fix pump
git-elliot Nov 10, 2024
f9311cc
some tests pass
git-elliot Nov 10, 2024
3186403
comment
git-elliot Nov 10, 2024
3575ded
duration added
git-elliot Nov 10, 2024
ff85ab4
fix
git-elliot Nov 10, 2024
019fa7f
fixed everything
git-elliot Nov 10, 2024
75fceb4
works in local
git-elliot Nov 10, 2024
04996c9
tests
git-elliot Nov 10, 2024
de75d74
work it man
git-elliot Nov 10, 2024
1c51097
only on main branch
git-elliot Nov 10, 2024
6625d38
let it settle
git-elliot Nov 10, 2024
960f9a7
Merge pull request #205 from osociety/integration-tests
git-elliot Nov 10, 2024
a74b540
Merge branch 'main' into dev
git-elliot Nov 10, 2024
a504319
changed keys to widgetkeys
git-elliot Nov 12, 2024
e5e9d13
fix tests
git-elliot Nov 12, 2024
ede13f5
fix analyzer warnings
git-elliot Nov 12, 2024
82c4e89
fix tests
git-elliot Nov 12, 2024
e823730
should fix it
git-elliot Nov 12, 2024
e23f6c2
fix test
git-elliot Nov 12, 2024
68bf02a
fix tests
git-elliot Nov 12, 2024
7217db0
fixed tests
git-elliot Nov 12, 2024
8003320
remove portscan test
git-elliot Nov 12, 2024
4ab7fa3
remove import
git-elliot Nov 12, 2024
36e7487
Fix for slowness of device scan
git-elliot Nov 16, 2024
fa12b7b
Prepare release v1.1.0+29
git-elliot Nov 16, 2024
413949e
Merge pull request #207 from osociety/fix-ui-slowness
git-elliot Nov 16, 2024
7fa041b
Added coverage action
git-elliot Nov 16, 2024
0b69b0c
added codecov badge
git-elliot Nov 16, 2024
8f05522
Merge branch 'dev' into fix-ui-slowness
git-elliot Nov 16, 2024
73f720a
Merge pull request #208 from osociety/fix-ui-slowness
git-elliot Nov 16, 2024
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
9 changes: 0 additions & 9 deletions .github/workflows/flutter_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ jobs:
- name: Download pub dependencies
run: flutter pub get

- name: Upgrade pub dependencies
run: flutter pub upgrade

- name: Run build_runner
run: dart run build_runner build --delete-conflicting-outputs

Expand Down Expand Up @@ -150,9 +147,6 @@ jobs:
- name: Download pub dependencies
run: flutter pub get

- name: Upgrade pub dependencies
run: flutter pub upgrade

- name: Run build_runner
run: dart run build_runner build --delete-conflicting-outputs

Expand Down Expand Up @@ -204,9 +198,6 @@ jobs:
- name: Download pub dependencies
run: flutter pub get

- name: Upgrade pub dependencies
run: flutter pub upgrade

- name: Run build_runner
run: dart run build_runner build --delete-conflicting-outputs

Expand Down
27 changes: 17 additions & 10 deletions .github/workflows/flutter_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_call:

concurrency:
group: ${{ github.head_ref }}
group: ${{ github.head_ref || github.run_id}}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -51,10 +51,14 @@ jobs:
name: 'Flutter Analyze + Test'
needs: changes
if: ${{ needs.changes.outputs.lib == 'true' || needs.changes.outputs.test == 'true' || needs.changes.outputs.yaml == 'true' || needs.changes.outputs.android == 'true' || needs.changes.outputs.linux == 'true' || needs.changes.outputs.macos == 'true' || needs.changes.outputs.windows == 'true' }}
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Setup Java JDK
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -85,14 +89,23 @@ jobs:
build-runner-
- name: Download pub dependencies
run: flutter pub get
- name: Upgrade pub dependencies
run: flutter pub upgrade
- name: Run build_runner
run: flutter pub run build_runner build
- name: Run analyzer
run: flutter analyze
- name: Install coverage tools
run: flutter pub global activate coverage
- name: Run tests
run: flutter test
- name: Run integration tests
if: ${{ steps.extract_branch.outputs.branch == 'dev' }}
run: flutter test integration_test --coverage -d macos
- name: Upload Coverage to CodeCov
if: ${{ steps.extract_branch.outputs.branch == 'dev' }}
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
file: coverage/lcov.info

android-linux-build:
name: 'Build Android + Linux'
Expand Down Expand Up @@ -130,8 +143,6 @@ jobs:
build-runner-
- name: Download pub dependencies
run: flutter pub get
- name: Upgrade pub dependencies
run: flutter pub upgrade
- name: Run build_runner
run: flutter pub run build_runner build
- name: Build Android
Expand Down Expand Up @@ -186,8 +197,6 @@ jobs:
${{ runner.os }}-pods-
- name: Download pub dependencies
run: flutter pub get
- name: Upgrade pub dependencies
run: flutter pub upgrade
- name: Run build_runner
run: flutter pub run build_runner build
- name: Build macos
Expand Down Expand Up @@ -224,8 +233,6 @@ jobs:
build-runner-
- name: Download pub dependencies
run: flutter pub get
- name: Upgrade pub dependencies
run: flutter pub upgrade
- name: Run build_runner
run: flutter pub run build_runner build
- name: Build windows
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Vernet - Network Analyzer and Monitoring Tool
![GitHub repo size](https://img.shields.io/github/repo-size/git-elliot/vernet)
![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/osociety/vernet/total)
![Liberapay receiving](https://img.shields.io/liberapay/receives/opensociety)
[![codecov](https://codecov.io/gh/osociety/vernet/graph/badge.svg?token=B25JBP4RCI)](https://codecov.io/gh/osociety/vernet)

## Features

Expand Down
1 change: 1 addition & 0 deletions android/fastlane/metadata/android/en-US/changelogs/29.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed slowness of devices scan.
2 changes: 2 additions & 0 deletions generate_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
genhtml coverage/lcov.info -o coverage/html
open coverage/html/index.html
88 changes: 88 additions & 0 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_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/keys.dart';

void main() {
late ServerSocket server;
int port = 0;
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
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('just test if app is able to launch and display homepage',
(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));
});

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();
await tester.pump();
expect(find.byType(AdaptiveListTile), findsAtLeast(2));

final routerIconButton =
find.byKey(WidgetKey.thisDeviceTileIconButton.key);

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();
});
}
4 changes: 4 additions & 0 deletions lib/helper/app_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@
_customSubnet;
debugPrint("Custom Subnet : $_customSubnet");
}

Future<bool> clearAll() async {
return (await SharedPreferences.getInstance()).clear();

Check warning on line 118 in lib/helper/app_settings.dart

View check run for this annotation

Codecov / codecov/patch

lib/helper/app_settings.dart#L117-L118

Added lines #L117 - L118 were not covered by tests
}
}
5 changes: 4 additions & 1 deletion lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:vernet/repository/notification_service.dart';
import 'package:vernet/services/impls/device_scanner_service.dart';
import 'package:vernet/ui/adaptive/adaptive_list.dart';
import 'package:vernet/ui/custom_tile.dart';
import 'package:vernet/values/keys.dart';
import 'package:vernet/values/strings.dart';

class HomePage extends StatefulWidget {
Expand Down Expand Up @@ -168,6 +169,7 @@ class _WifiDetailState extends State<HomePage> {
width: 4,
),
ElevatedButton(
key: WidgetKey.scanForDevicesButton.key,
onPressed: () {
Navigator.push(
context,
Expand All @@ -192,7 +194,7 @@ class _WifiDetailState extends State<HomePage> {
} else if (snapshot.hasError) {
return const Text("Unable to fetch WiFi details");
} else {
return const CircularProgressIndicator.adaptive();
return const Text('Loading...');
}
},
),
Expand Down Expand Up @@ -221,6 +223,7 @@ class _WifiDetailState extends State<HomePage> {
),
const SizedBox(width: 10),
ElevatedButton.icon(
key: WidgetKey.scanForOpenPortsButton.key,
onPressed: () {
Navigator.push(
context,
Expand Down
15 changes: 7 additions & 8 deletions lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import 'package:vernet/helper/utils_helper.dart';
import 'package:vernet/injection.dart';
import 'package:vernet/main.dart';
import 'package:vernet/models/device_in_the_network.dart';
import 'package:vernet/models/isar/device.dart';
import 'package:vernet/models/isar/scan.dart';
import 'package:vernet/repository/notification_service.dart';
Expand Down Expand Up @@ -38,7 +37,7 @@
String? subnet;

/// List of all ActiveHost devices that got found in the current scan
final List<DeviceInTheNetwork> deviceInTheNetworkList = [];
final Set<Device> devicesSet = {};

/// mDNS for each ip
final Map<String, MdnsInfo> mDnsDevices = {};
Expand All @@ -47,7 +46,7 @@
Initialized event,
Emitter<HostScanState> emit,
) async {
deviceInTheNetworkList.clear();
devicesSet.clear();
mDnsDevices.clear();
emit(const HostScanState.loadInProgress());
await initializeWifiParameters(emit);
Expand Down Expand Up @@ -82,16 +81,16 @@
) async {
emit(const HostScanState.loadInProgress());

final Set<Device> devices = {};
final deviceStream =
getIt<DeviceScannerService>().startNewScan(subnet!, ip!, gatewayIp!);
await for (final Device device in deviceStream) {
devices.add(device);
emit(HostScanState.foundNewDevice(devices));
devicesSet.add(device);
emit(const HostScanState.loadInProgress());
emit(HostScanState.foundNewDevice(devicesSet));
}

await NotificationService.showNotificationWithActions();
emit(HostScanState.loadSuccess(devices));
emit(HostScanState.loadSuccess(devicesSet));

Check warning on line 93 in lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart#L93

Added line #L93 was not covered by tests
}

Future<void> _loadScanAndShowResults(
Expand All @@ -100,10 +99,10 @@
) async {
emit(const HostScanState.loadInProgress());

final Set<Device> devicesSet = {};
final deviceStream = await getIt<DeviceScannerService>().getOnGoingScan();
deviceStream.listen((devices) {
devicesSet.addAll(devices);
emit(const HostScanState.loadInProgress());

Check warning on line 105 in lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart#L105

Added line #L105 was not covered by tests
emit(HostScanState.foundNewDevice(devicesSet));
});

Expand Down
20 changes: 10 additions & 10 deletions lib/pages/host_scan_page/widgets/host_scan_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import 'package:vernet/pages/host_scan_page/host_scan_bloc/host_scan_bloc.dart';
import 'package:vernet/pages/network_troubleshoot/port_scan_page.dart';
import 'package:vernet/ui/adaptive/adaptive_list.dart';
import 'package:vernet/values/keys.dart';
import 'package:vernet/values/strings.dart';
import 'package:vernet/values/tooltip_messages.dart';

//TODO: Device doesn't refresh when active scan going on
class HostScanWidget extends StatelessWidget {
Expand All @@ -29,7 +32,7 @@
Text(
appSettings.gatewayIP.isNotEmpty
? 'Searching for devices in ${appSettings.gatewayIP} network'
: 'Searching for devices in your local network',
: StringValue.loadingDevicesMessage,

Check warning on line 35 in lib/pages/host_scan_page/widgets/host_scan_widget.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/host_scan_page/widgets/host_scan_widget.dart#L35

Added line #L35 was not covered by tests
textAlign: TextAlign.center,
),
],
Expand Down Expand Up @@ -68,15 +71,9 @@
textAlign: TextAlign.center,
),
trailing: loading
? const Padding(
padding: EdgeInsets.all(8.0),
child: SizedBox(
height: 25.0,
width: 25.0,
child: Center(child: CircularProgressIndicator.adaptive()),
),
)
? const SizedBox()
: IconButton(
key: WidgetKey.rescanIconButton.key,

Check warning on line 76 in lib/pages/host_scan_page/widgets/host_scan_widget.dart

View check run for this annotation

Codecov / codecov/patch

lib/pages/host_scan_page/widgets/host_scan_widget.dart#L76

Added line #L76 was not covered by tests
onPressed: () {
context
.read<HostScanBloc>()
Expand All @@ -97,7 +94,10 @@
'${host.internetAddress}, ${host.macAddress ?? ''}',
),
trailing: IconButton(
tooltip: 'Scan open ports for this target',
key: host.deviceMake == 'This device'
? WidgetKey.thisDeviceTileIconButton.key
: null,
tooltip: TooltipMessages.currentDevicePortScan,
icon: const Icon(Icons.radar),
onPressed: () {
Navigator.push(
Expand Down
Loading