发布网络质量探测 1.1.2:更新测试、版本号与协议说明
署名:言灸
This commit is contained in:
1 parent
c1a60eef43
commit
3776ece7a4
4 files changed
+373
-229
No files matched your search
+1
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.1.1+4
|
version: 1.1.2+5
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.13.7
|
sdk: ^3.13.7
|
||||||
|
|||||||
+253
-226
@@ -25,238 +25,261 @@ void main() {
|
|||||||
expect(build.exitCode, 0, reason: '${build.stdout}\n${build.stderr}');
|
expect(build.exitCode, 0, reason: '${build.stdout}\n${build.stderr}');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('local nq tcp and udp get real rtt and do not call connect failure loss', () async {
|
test(
|
||||||
final reflector = await _reflector();
|
'local nq tcp and udp get real rtt and do not call connect failure loss',
|
||||||
addTearDown(() => reflector.process.kill());
|
() async {
|
||||||
final tcp = await _collect(
|
final reflector = await _reflector();
|
||||||
ProbeRequest(
|
addTearDown(() => reflector.process.kill());
|
||||||
host: '127.0.0.1',
|
final tcp = await _collect(
|
||||||
port: reflector.tcp,
|
ProbeRequest(
|
||||||
profileId: 'nq-tcp',
|
host: '127.0.0.1',
|
||||||
interval: const Duration(milliseconds: 200),
|
port: reflector.tcp,
|
||||||
timeout: const Duration(milliseconds: 800),
|
profileId: 'nq-tcp',
|
||||||
packetSize: 80,
|
interval: const Duration(milliseconds: 200),
|
||||||
echoToken: '',
|
timeout: const Duration(milliseconds: 800),
|
||||||
dnsName: '',
|
packetSize: 80,
|
||||||
payloadHex: '',
|
echoToken: '',
|
||||||
expectHex: '',
|
dnsName: '',
|
||||||
),
|
payloadHex: '',
|
||||||
count: 2,
|
expectHex: '',
|
||||||
);
|
),
|
||||||
expect(tcp.last.status, Outcome.ok);
|
count: 2,
|
||||||
expect(tcp.last.rttMs, greaterThan(0));
|
);
|
||||||
expect(tcp.last.summary.probeLossPct, 0);
|
expect(tcp.last.status, Outcome.ok);
|
||||||
|
expect(tcp.last.rttMs, greaterThan(0));
|
||||||
|
expect(tcp.last.summary.probeLossPct, 0);
|
||||||
|
|
||||||
final udp = await _collect(
|
final udp = await _collect(
|
||||||
ProbeRequest(
|
ProbeRequest(
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: reflector.udp,
|
port: reflector.udp,
|
||||||
profileId: 'nq-udp',
|
profileId: 'nq-udp',
|
||||||
interval: const Duration(milliseconds: 200),
|
interval: const Duration(milliseconds: 200),
|
||||||
timeout: const Duration(milliseconds: 800),
|
timeout: const Duration(milliseconds: 800),
|
||||||
packetSize: 80,
|
packetSize: 80,
|
||||||
echoToken: '',
|
echoToken: '',
|
||||||
dnsName: '',
|
dnsName: '',
|
||||||
payloadHex: '',
|
payloadHex: '',
|
||||||
expectHex: '',
|
expectHex: '',
|
||||||
),
|
),
|
||||||
count: 1,
|
count: 1,
|
||||||
);
|
);
|
||||||
expect(udp.single.status, Outcome.ok);
|
expect(udp.single.status, Outcome.ok);
|
||||||
expect(udp.single.summary.probeLossPct, 0);
|
expect(udp.single.summary.probeLossPct, 0);
|
||||||
|
|
||||||
final refused = await _collect(
|
final refused = await _collect(
|
||||||
ProbeRequest(
|
ProbeRequest(
|
||||||
host: '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
port: 1,
|
port: 1,
|
||||||
profileId: 'tcp-connect',
|
profileId: 'tcp-connect',
|
||||||
interval: const Duration(milliseconds: 200),
|
interval: const Duration(milliseconds: 200),
|
||||||
timeout: const Duration(milliseconds: 400),
|
timeout: const Duration(milliseconds: 400),
|
||||||
packetSize: 64,
|
packetSize: 64,
|
||||||
echoToken: '',
|
echoToken: '',
|
||||||
dnsName: '',
|
dnsName: '',
|
||||||
payloadHex: '',
|
payloadHex: '',
|
||||||
expectHex: '',
|
expectHex: '',
|
||||||
),
|
),
|
||||||
count: 1,
|
count: 1,
|
||||||
);
|
);
|
||||||
expect(refused.single.status, Outcome.refused);
|
expect(refused.single.status, Outcome.refused);
|
||||||
expect(refused.single.summary.failurePct, 100);
|
expect(refused.single.summary.failurePct, 100);
|
||||||
expect(refused.single.summary.probeLossPct, isNull);
|
expect(refused.single.summary.probeLossPct, isNull);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test('silence is unknown, games answer, and a remote node measures rtt', () async {
|
test(
|
||||||
final hole = await RawDatagramSocket.bind(InternetAddress.loopbackIPv4, 0);
|
'silence is unknown, games answer, and a remote node measures rtt',
|
||||||
addTearDown(hole.close);
|
() async {
|
||||||
hole.listen((event) {
|
final hole = await RawDatagramSocket.bind(
|
||||||
if (event == RawSocketEvent.read) {
|
InternetAddress.loopbackIPv4,
|
||||||
hole.receive();
|
0,
|
||||||
}
|
);
|
||||||
});
|
addTearDown(hole.close);
|
||||||
final unknown = await _collect(
|
hole.listen((event) {
|
||||||
ProbeRequest(
|
if (event == RawSocketEvent.read) {
|
||||||
host: '127.0.0.1',
|
hole.receive();
|
||||||
port: hole.port,
|
|
||||||
profileId: 'udp-generic',
|
|
||||||
interval: const Duration(milliseconds: 200),
|
|
||||||
timeout: const Duration(milliseconds: 200),
|
|
||||||
packetSize: 16,
|
|
||||||
echoToken: '',
|
|
||||||
dnsName: '',
|
|
||||||
payloadHex: '',
|
|
||||||
expectHex: '',
|
|
||||||
),
|
|
||||||
count: 1,
|
|
||||||
);
|
|
||||||
expect(unknown.single.status, Outcome.unknown);
|
|
||||||
expect(unknown.single.summary.probeLossPct, isNull);
|
|
||||||
expect(unknown.single.summary.unknownPct, 100);
|
|
||||||
expect(unknown.single.detail['address'], '127.0.0.1');
|
|
||||||
|
|
||||||
final java = await _javaServer();
|
|
||||||
addTearDown(java.close);
|
|
||||||
final javaSample = await _collect(
|
|
||||||
ProbeRequest(
|
|
||||||
host: '127.0.0.1',
|
|
||||||
port: java.port,
|
|
||||||
profileId: 'minecraft-java',
|
|
||||||
interval: const Duration(milliseconds: 200),
|
|
||||||
timeout: const Duration(milliseconds: 800),
|
|
||||||
packetSize: 64,
|
|
||||||
echoToken: '',
|
|
||||||
dnsName: '',
|
|
||||||
payloadHex: '',
|
|
||||||
expectHex: '',
|
|
||||||
),
|
|
||||||
count: 1,
|
|
||||||
);
|
|
||||||
expect(javaSample.single.status, Outcome.ok);
|
|
||||||
expect(javaSample.single.detail['motd'], 'Hello');
|
|
||||||
expect(javaSample.single.rttMs, greaterThan(0));
|
|
||||||
expect(javaSample.single.summary.failurePct, 0);
|
|
||||||
|
|
||||||
final bedrock = await _bedrockServer();
|
|
||||||
addTearDown(bedrock.close);
|
|
||||||
final bedrockSample = await _collect(
|
|
||||||
ProbeRequest(
|
|
||||||
host: '127.0.0.1',
|
|
||||||
port: bedrock.port,
|
|
||||||
profileId: 'minecraft-bedrock',
|
|
||||||
interval: const Duration(milliseconds: 200),
|
|
||||||
timeout: const Duration(milliseconds: 800),
|
|
||||||
packetSize: 64,
|
|
||||||
echoToken: '',
|
|
||||||
dnsName: '',
|
|
||||||
payloadHex: '',
|
|
||||||
expectHex: '',
|
|
||||||
),
|
|
||||||
count: 1,
|
|
||||||
);
|
|
||||||
expect(bedrockSample.single.status, Outcome.ok);
|
|
||||||
expect(bedrockSample.single.detail['motd'], 'Bed');
|
|
||||||
|
|
||||||
final node = await _node();
|
|
||||||
addTearDown(node.kill);
|
|
||||||
final samples = <ProbeSample>[];
|
|
||||||
final remote = RemoteProbe();
|
|
||||||
final done = Completer<void>();
|
|
||||||
unawaited(() async {
|
|
||||||
try {
|
|
||||||
await remote.run(
|
|
||||||
baseUrl: 'http://127.0.0.1:${node.control}',
|
|
||||||
nodeToken: '',
|
|
||||||
body: ProbeBody(
|
|
||||||
target: '127.0.0.1',
|
|
||||||
port: node.udp,
|
|
||||||
profile: 'nq-udp',
|
|
||||||
intervalMs: 200,
|
|
||||||
timeoutMs: 800,
|
|
||||||
durationSec: 3,
|
|
||||||
packetSize: 80,
|
|
||||||
echoToken: '',
|
|
||||||
dnsName: '',
|
|
||||||
payloadHex: '',
|
|
||||||
expectHex: '',
|
|
||||||
),
|
|
||||||
onSample: (sample) {
|
|
||||||
samples.add(sample);
|
|
||||||
if (samples.length == 1 && !done.isCompleted) {
|
|
||||||
done.complete();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cancelled: () => done.isCompleted,
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
if (!done.isCompleted) {
|
|
||||||
done.complete();
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}());
|
final unknown = await _collect(
|
||||||
await done.future.timeout(const Duration(seconds: 5));
|
ProbeRequest(
|
||||||
await remote.stop('');
|
host: '127.0.0.1',
|
||||||
expect(samples, isNotEmpty);
|
port: hole.port,
|
||||||
expect(samples.first.status, Outcome.ok);
|
profileId: 'udp-generic',
|
||||||
expect(samples.first.rttMs, greaterThan(0));
|
interval: const Duration(milliseconds: 200),
|
||||||
expect(samples.first.summary.probeLossPct, 0);
|
timeout: const Duration(milliseconds: 200),
|
||||||
});
|
packetSize: 16,
|
||||||
|
echoToken: '',
|
||||||
|
dnsName: '',
|
||||||
|
payloadHex: '',
|
||||||
|
expectHex: '',
|
||||||
|
),
|
||||||
|
count: 1,
|
||||||
|
);
|
||||||
|
expect(unknown.single.status, Outcome.unknown);
|
||||||
|
expect(unknown.single.summary.probeLossPct, isNull);
|
||||||
|
expect(unknown.single.summary.unknownPct, 100);
|
||||||
|
expect(unknown.single.detail['address'], '127.0.0.1');
|
||||||
|
|
||||||
test('plain udp leaves a silent address and keeps one that answers', () async {
|
final java = await _javaServer();
|
||||||
final drop = await RawDatagramSocket.bind(InternetAddress.loopbackIPv4, 0);
|
addTearDown(java.close);
|
||||||
addTearDown(drop.close);
|
final javaSample = await _collect(
|
||||||
final port = drop.port;
|
ProbeRequest(
|
||||||
drop.listen((event) {
|
host: '127.0.0.1',
|
||||||
if (event == RawSocketEvent.read) {
|
port: java.port,
|
||||||
drop.receive();
|
profileId: 'minecraft-java',
|
||||||
}
|
interval: const Duration(milliseconds: 200),
|
||||||
});
|
timeout: const Duration(milliseconds: 800),
|
||||||
final RawDatagramSocket echo;
|
packetSize: 64,
|
||||||
try {
|
echoToken: '',
|
||||||
echo = await RawDatagramSocket.bind(InternetAddress.loopbackIPv6, port);
|
dnsName: '',
|
||||||
} on SocketException {
|
payloadHex: '',
|
||||||
markTestSkipped('IPv6 loopback is not available');
|
expectHex: '',
|
||||||
return;
|
),
|
||||||
}
|
count: 1,
|
||||||
addTearDown(echo.close);
|
);
|
||||||
echo.listen((event) {
|
expect(javaSample.single.status, Outcome.ok);
|
||||||
if (event != RawSocketEvent.read) {
|
expect(javaSample.single.detail['motd'], 'Hello');
|
||||||
|
expect(javaSample.single.rttMs, greaterThan(0));
|
||||||
|
expect(javaSample.single.summary.failurePct, 0);
|
||||||
|
|
||||||
|
final bedrock = await _bedrockServer();
|
||||||
|
addTearDown(bedrock.close);
|
||||||
|
final bedrockSample = await _collect(
|
||||||
|
ProbeRequest(
|
||||||
|
host: '127.0.0.1',
|
||||||
|
port: bedrock.port,
|
||||||
|
profileId: 'minecraft-bedrock',
|
||||||
|
interval: const Duration(milliseconds: 200),
|
||||||
|
timeout: const Duration(milliseconds: 800),
|
||||||
|
packetSize: 64,
|
||||||
|
echoToken: '',
|
||||||
|
dnsName: '',
|
||||||
|
payloadHex: '',
|
||||||
|
expectHex: '',
|
||||||
|
),
|
||||||
|
count: 1,
|
||||||
|
);
|
||||||
|
expect(bedrockSample.single.status, Outcome.ok);
|
||||||
|
expect(bedrockSample.single.detail['motd'], 'Bed');
|
||||||
|
|
||||||
|
final node = await _node();
|
||||||
|
addTearDown(node.kill);
|
||||||
|
final samples = <ProbeSample>[];
|
||||||
|
final remote = RemoteProbe();
|
||||||
|
final done = Completer<void>();
|
||||||
|
unawaited(() async {
|
||||||
|
try {
|
||||||
|
await remote.run(
|
||||||
|
baseUrl: 'http://127.0.0.1:${node.control}',
|
||||||
|
nodeToken: '',
|
||||||
|
body: ProbeBody(
|
||||||
|
target: '127.0.0.1',
|
||||||
|
port: node.udp,
|
||||||
|
profile: 'nq-udp',
|
||||||
|
intervalMs: 200,
|
||||||
|
timeoutMs: 800,
|
||||||
|
durationSec: 3,
|
||||||
|
packetSize: 80,
|
||||||
|
echoToken: '',
|
||||||
|
dnsName: '',
|
||||||
|
payloadHex: '',
|
||||||
|
expectHex: '',
|
||||||
|
),
|
||||||
|
onSample: (sample) {
|
||||||
|
samples.add(sample);
|
||||||
|
if (samples.length == 1 && !done.isCompleted) {
|
||||||
|
done.complete();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cancelled: () => done.isCompleted,
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
if (!done.isCompleted) {
|
||||||
|
done.complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
await done.future.timeout(const Duration(seconds: 5));
|
||||||
|
await remote.stop('');
|
||||||
|
expect(samples, isNotEmpty);
|
||||||
|
expect(samples.first.status, Outcome.ok);
|
||||||
|
expect(samples.first.rttMs, greaterThan(0));
|
||||||
|
expect(samples.first.summary.probeLossPct, 0);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'a silent candidate is not a measured miss once another address answers',
|
||||||
|
() async {
|
||||||
|
final drop = await RawDatagramSocket.bind(
|
||||||
|
InternetAddress.loopbackIPv4,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
addTearDown(drop.close);
|
||||||
|
final port = drop.port;
|
||||||
|
drop.listen((event) {
|
||||||
|
if (event == RawSocketEvent.read) {
|
||||||
|
drop.receive();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final RawDatagramSocket echo;
|
||||||
|
try {
|
||||||
|
echo = await RawDatagramSocket.bind(InternetAddress.loopbackIPv6, port);
|
||||||
|
} on SocketException {
|
||||||
|
markTestSkipped('IPv6 loopback is not available');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final datagram = echo.receive();
|
addTearDown(echo.close);
|
||||||
if (datagram == null) {
|
echo.listen((event) {
|
||||||
return;
|
if (event != RawSocketEvent.read) {
|
||||||
}
|
return;
|
||||||
echo.send(datagram.data, datagram.address, datagram.port);
|
}
|
||||||
});
|
final datagram = echo.receive();
|
||||||
|
if (datagram == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
echo.send(datagram.data, datagram.address, datagram.port);
|
||||||
|
});
|
||||||
|
|
||||||
final seen = <String>[];
|
final seen = <String>[];
|
||||||
final samples = await _collect(
|
final samples = await _collect(
|
||||||
ProbeRequest(
|
ProbeRequest(
|
||||||
host: 'example.test',
|
host: 'example.test',
|
||||||
port: port,
|
port: port,
|
||||||
profileId: 'udp-generic',
|
profileId: 'udp-generic',
|
||||||
interval: const Duration(milliseconds: 40),
|
interval: const Duration(milliseconds: 40),
|
||||||
timeout: const Duration(milliseconds: 250),
|
timeout: const Duration(milliseconds: 250),
|
||||||
packetSize: 16,
|
packetSize: 16,
|
||||||
echoToken: '',
|
echoToken: '',
|
||||||
dnsName: '',
|
dnsName: '',
|
||||||
payloadHex: '',
|
payloadHex: '',
|
||||||
expectHex: '',
|
expectHex: '',
|
||||||
),
|
),
|
||||||
count: 2,
|
count: 2,
|
||||||
loop: ProbeLoop(
|
loop: ProbeLoop(
|
||||||
lookup: (host) async {
|
lookup: (host) async {
|
||||||
expect(host, 'example.test');
|
expect(host, 'example.test');
|
||||||
return [InternetAddress('127.0.0.1'), InternetAddress('::1')];
|
return [InternetAddress('127.0.0.1'), InternetAddress('::1')];
|
||||||
},
|
},
|
||||||
onEndpoint: (address) => seen.add(address.address),
|
onEndpoint: (address) => seen.add(address.address),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(samples.first.status, Outcome.unknown);
|
expect(samples.first.status, Outcome.ok);
|
||||||
expect(samples.first.detail['address'], '127.0.0.1');
|
expect(samples.first.detail['address'], '::1');
|
||||||
expect(samples.last.status, Outcome.ok);
|
expect(samples.first.detail['family'], 'IPv6');
|
||||||
expect(samples.last.detail['address'], '::1');
|
expect(samples.first.detail['fallback'], contains('127.0.0.1'));
|
||||||
expect(seen, ['127.0.0.1', '::1']);
|
expect(samples.first.detail['fallback'], contains('没有计入'));
|
||||||
});
|
expect(samples.first.summary.sent, 1);
|
||||||
|
expect(samples.first.summary.unknown, 0);
|
||||||
|
expect(samples.first.summary.selectionSkipped, 1);
|
||||||
|
expect(samples.first.summary.unknownPct, 0);
|
||||||
|
expect(samples.last.status, Outcome.ok);
|
||||||
|
expect(samples.last.detail['address'], '::1');
|
||||||
|
expect(samples.last.summary.unknown, 0);
|
||||||
|
expect(seen, ['127.0.0.1', '::1']);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test('a responding address is not replaced while it still answers', () async {
|
test('a responding address is not replaced while it still answers', () async {
|
||||||
final echo = await RawDatagramSocket.bind(InternetAddress.loopbackIPv4, 0);
|
final echo = await RawDatagramSocket.bind(InternetAddress.loopbackIPv4, 0);
|
||||||
@@ -293,7 +316,10 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(samples.map((sample) => sample.status), everyElement(Outcome.ok));
|
expect(samples.map((sample) => sample.status), everyElement(Outcome.ok));
|
||||||
expect(samples.map((sample) => sample.detail['address']), everyElement('127.0.0.1'));
|
expect(
|
||||||
|
samples.map((sample) => sample.detail['address']),
|
||||||
|
everyElement('127.0.0.1'),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,7 +363,8 @@ Future<({Process process, int tcp, int udp})> _reflector() async {
|
|||||||
return (process: process, tcp: tcp, udp: udp);
|
return (process: process, tcp: tcp, udp: udp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<({Process process, int control, int udp, void Function() kill})> _node() async {
|
Future<({Process process, int control, int udp, void Function() kill})>
|
||||||
|
_node() async {
|
||||||
final udp = await _freeUdp();
|
final udp = await _freeUdp();
|
||||||
final control = await _freeTcp();
|
final control = await _freeTcp();
|
||||||
final process = await Process.start(binary, [
|
final process = await Process.start(binary, [
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:netquality/main.dart';
|
import 'package:netquality/main.dart';
|
||||||
@@ -27,7 +29,9 @@ void main() {
|
|||||||
const config = SessionConfig(
|
const config = SessionConfig(
|
||||||
remote: true,
|
remote: true,
|
||||||
nodeId: 'n1',
|
nodeId: 'n1',
|
||||||
nodes: [RemoteNode(id: 'n1', name: '机房', baseUrl: 'https://probe.example:8443')],
|
nodes: [
|
||||||
|
RemoteNode(id: 'n1', name: '机房', baseUrl: 'https://probe.example:8443'),
|
||||||
|
],
|
||||||
host: '203.0.113.8',
|
host: '203.0.113.8',
|
||||||
port: 25565,
|
port: 25565,
|
||||||
profileId: 'minecraft-java',
|
profileId: 'minecraft-java',
|
||||||
@@ -47,4 +51,115 @@ void main() {
|
|||||||
expect(again.toJson().containsKey('nodeToken'), isFalse);
|
expect(again.toJson().containsKey('nodeToken'), isFalse);
|
||||||
expect(SessionConfig.defaults.validate(), isNull);
|
expect(SessionConfig.defaults.validate(), isNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'profile default port updates until the user types another port',
|
||||||
|
(tester) async {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
tester.view.physicalSize = const Size(1280, 1600);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
await tester.pumpWidget(const NetQualityApp());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(find.text('合作反射 TCP 默认 19090'), findsOneWidget);
|
||||||
|
await tester.ensureVisible(find.byKey(const Key('profile')));
|
||||||
|
await tester.tap(find.byKey(const Key('profile')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('合作反射 UDP').last);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('19091'), findsWidgets);
|
||||||
|
expect(find.text('合作反射 UDP 默认 19091'), findsOneWidget);
|
||||||
|
|
||||||
|
await tester.enterText(find.byKey(const Key('port-field')), '25565');
|
||||||
|
await tester.tap(find.byKey(const Key('profile')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('合作反射 TCP').last);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('25565'), findsOneWidget);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
testWidgets('editing a node keeps its id and does not reveal the token', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
tester.view.physicalSize = const Size(1280, 1600);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
await tester.pumpWidget(const NetQualityApp());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text('远程节点').first);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('管理节点'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.enterText(find.byKey(const Key('node-name')), '机房');
|
||||||
|
await tester.enterText(
|
||||||
|
find.byKey(const Key('node-url')),
|
||||||
|
'http://127.0.0.1:8443',
|
||||||
|
);
|
||||||
|
await tester.enterText(find.byKey(const Key('node-token')), 'saved-secret');
|
||||||
|
await tester.tap(find.byKey(const Key('node-save')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.text('编辑'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final token = tester.widget<TextField>(find.byKey(const Key('node-token')));
|
||||||
|
expect(token.controller?.text, isEmpty);
|
||||||
|
expect(find.text('saved-secret'), findsNothing);
|
||||||
|
await tester.enterText(find.byKey(const Key('node-name')), '机房乙');
|
||||||
|
await tester.tap(find.text('保存修改'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.textContaining('机房乙'), findsWidgets);
|
||||||
|
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final raw = prefs.getString('netquality.settings.v2') ?? '';
|
||||||
|
expect(raw, contains('机房乙'));
|
||||||
|
expect(raw, isNot(contains('saved-secret')));
|
||||||
|
final decoded = jsonDecode(raw) as Map<String, dynamic>;
|
||||||
|
final nodes = decoded['nodes'] as List<dynamic>;
|
||||||
|
expect(nodes, hasLength(1));
|
||||||
|
final node = nodes.single as Map<String, dynamic>;
|
||||||
|
expect(node['name'], '机房乙');
|
||||||
|
expect(node['baseUrl'], 'http://127.0.0.1:8443');
|
||||||
|
expect(decoded['nodeId'], node['id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('guide and history screens use the real versions', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
SharedPreferences.setMockInitialValues({});
|
||||||
|
tester.view.physicalSize = const Size(900, 1400);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
await tester.pumpWidget(const NetQualityApp());
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
await tester.tap(find.byType(PopupMenuButton<String>));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('指标说明'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.textContaining('没有协议应答'), findsWidgets);
|
||||||
|
await tester.scrollUntilVisible(find.text('选址失败和正式丢包'), 200);
|
||||||
|
expect(find.text('选址失败和正式丢包'), findsOneWidget);
|
||||||
|
await tester.scrollUntilVisible(find.textContaining('RFC 3550'), 200);
|
||||||
|
expect(find.textContaining('RFC 3550'), findsOneWidget);
|
||||||
|
|
||||||
|
await tester.pageBack();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byType(PopupMenuButton<String>));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('更新历史'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('网络质量探测 1.1.2'), findsOneWidget);
|
||||||
|
await tester.scrollUntilVisible(find.text('网络质量探测 1.1.1'), 200);
|
||||||
|
expect(find.text('网络质量探测 1.1.1'), findsOneWidget);
|
||||||
|
expect(find.textContaining('言灸'), findsOneWidget);
|
||||||
|
expect(find.textContaining('v1.1.1'), findsWidgets);
|
||||||
|
expect(find.text('网络质量探测 1.1.0'), findsNothing);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+3
-1
@@ -44,7 +44,9 @@
|
|||||||
- **普通 TCP**:只记录连接耗时、成功或失败、连续失败。没有自定义帧。
|
- **普通 TCP**:只记录连接耗时、成功或失败、连续失败。没有自定义帧。
|
||||||
- **普通 UDP、DNS、自定义 UDP、基岩版**:没有收到符合协议的包时记为无应答/未知,不叫丢包。内容不对记为协议错误。
|
- **普通 UDP、DNS、自定义 UDP、基岩版**:没有收到符合协议的包时记为无应答/未知,不叫丢包。内容不对记为协议错误。
|
||||||
- **Minecraft Java**:状态握手加上 ping/pong。往返时间只算 ping 到对上 nonce 的 pong。连不上或协议不对记为失败率。
|
- **Minecraft Java**:状态握手加上 ping/pong。往返时间只算 ping 到对上 nonce 的 pong。连不上或协议不对记为失败率。
|
||||||
- **抖动**:RFC 3550。相邻两次成功的往返时间差 `D`,`J = J + (|D| - J) / 16`。
|
- **抖动**:RFC 3550。相邻两次成功的往返时间差 `D`,`J = J + (|D| - J) / 16`。第一次成功时 J 为 0。
|
||||||
|
- **延迟分布**:只统计成功样本。当前延迟是最近一次成功。最小、最大是极值。平均是算术平均。中位数在奇数个时取排序后的中间值,偶数个时取中间两个的平均。P95 用最近秩,秩 = ceil(0.95 × 次数),用整数 `(95 × 次数 + 99) / 100` 计算,从 1 起计。
|
||||||
|
- **选址**:一个名字解析出多个地址时,还没有任何地址应答之前的失败只用于挑选地址。后面有地址成功时,这些失败不进入已发送、超时和丢包,并在 `detail.fallback` 里说明。选定之后的失败照常计入。每个候选都失败时,这些失败计入正式结果,不能显示成 0% 成功。每条样本的 `detail.address` 和 `detail.family` 是这次实际连通或发包的地址;没有这个字段就表示节点没有报告,不能用解析结果代替。`summary` 另有 `minRttMs`、`meanRttMs`、`medianRttMs`、`p95RttMs`、`maxRttMs` 和 `selectionSkipped`。旧客户端会忽略不认识的字段。
|
||||||
|
|
||||||
## 控制接口
|
## 控制接口
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user