Skip to content

Commit 3c38c54

Browse files
committed
Check primary connection properties
1 parent 2224710 commit 3c38c54

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

test/nm_test.dart

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ class MockNetworkManagerManager extends MockNetworkManagerObject {
3535
DBusSignature('o'), server.devices.map((device) => device.path)),
3636
'Metered': DBusUint32(server.metered),
3737
'NetworkingEnabled': DBusBoolean(server.networkingEnabled),
38-
'PrimaryConnection':
39-
server.primaryConnection?.path ?? DBusObjectPath('/'),
40-
'PrimaryConnectionType':
41-
DBusString(server.primaryConnection?.type ?? ''),
38+
'PrimaryConnection': server.activeConnections.isNotEmpty
39+
? server.activeConnections[0].path
40+
: DBusObjectPath('/'),
41+
'PrimaryConnectionType': DBusString(
42+
server.activeConnections.isNotEmpty
43+
? server.activeConnections[0].type
44+
: ''),
4245
'Startup': DBusBoolean(server.startup),
4346
'State': DBusUint32(server.state),
4447
'Version': DBusString(server.version),
@@ -861,7 +864,6 @@ class MockNetworkManagerServer extends DBusClient {
861864
final devices = <MockNetworkManagerDevice>[];
862865
MockNetworkManagerActiveConnection? activatingConnection;
863866
final activeConnections = <MockNetworkManagerActiveConnection>[];
864-
MockNetworkManagerActiveConnection? primaryConnection;
865867
final connectionSettings = <MockNetworkManagerConnectionSettings>[];
866868

867869
MockNetworkManagerServer(DBusAddress clientAddress,
@@ -3050,6 +3052,27 @@ void main() {
30503052
expect(connection.vpn, isTrue);
30513053
});
30523054

3055+
test('primary connection', () async {
3056+
var server = DBusServer();
3057+
addTearDown(() async => await server.close());
3058+
var clientAddress =
3059+
await server.listenAddress(DBusAddress.unix(dir: Directory.systemTemp));
3060+
3061+
var nm = MockNetworkManagerServer(clientAddress);
3062+
addTearDown(() async => await nm.close());
3063+
await nm.start();
3064+
await nm.addActiveConnection(id: 'connection', type: '802-3-ethernet');
3065+
3066+
var client = NetworkManagerClient(bus: DBusClient(clientAddress));
3067+
addTearDown(() async => await client.close());
3068+
await client.connect();
3069+
3070+
expect(client.primaryConnection, isNotNull);
3071+
expect(client.primaryConnection!.id, equals('connection'));
3072+
expect(client.primaryConnection!.type, equals('802-3-ethernet'));
3073+
expect(client.primaryConnectionType, equals('802-3-ethernet'));
3074+
});
3075+
30533076
test('add connection', () async {
30543077
var server = DBusServer();
30553078
addTearDown(() async => await server.close());

0 commit comments

Comments
 (0)