@@ -1260,6 +1260,7 @@ public IEnumerator TestSendingWithSingleNotOverride()
1260
1260
1261
1261
}
1262
1262
1263
+ [ Timeout ( 1200000 ) ]
1263
1264
[ TestFixture ( HostOrServer . Host ) ]
1264
1265
[ TestFixture ( HostOrServer . Server ) ]
1265
1266
internal class UniversalRpcTestSendingWithGroupOverride : UniversalRpcTestsBase
@@ -1285,80 +1286,59 @@ public enum AllocationType
1285
1286
List
1286
1287
}
1287
1288
1288
- [ UnityTest ]
1289
- public IEnumerator TestSendingWithGroupOverride ( )
1289
+ // Extending timeout since the added yield return causes this test to commonly timeout
1290
+ [ Test ]
1291
+ public void TestSendingWithGroupOverride (
1292
+ [ Values ] SendTo defaultSendTo ,
1293
+ [ ValueSource ( nameof ( RecipientGroups ) ) ] ulong [ ] recipient ,
1294
+ [ Values ( 0u , 1u , 2u ) ] ulong objectOwner ,
1295
+ [ Values ( 0u , 1u , 2u ) ] ulong sender ,
1296
+ [ Values ] AllocationType allocationType
1297
+ )
1290
1298
{
1291
- var waitFor = new WaitForFixedUpdate ( ) ;
1292
- foreach ( var defaultSendTo in Enum . GetValues ( typeof ( SendTo ) ) )
1293
- {
1294
- m_EnableVerboseDebug = true ;
1295
- VerboseDebug ( $ "Processing: { defaultSendTo } ") ;
1296
- m_EnableVerboseDebug = false ;
1299
+ var sendMethodName = $ "DefaultTo{ defaultSendTo } AllowOverrideRpc";
1297
1300
1298
- foreach ( var recipient in RecipientGroups )
1299
- {
1300
- for ( ulong objectOwner = 0u ; objectOwner <= 2u ; ++ objectOwner )
1301
+ var senderObject = GetPlayerObject ( objectOwner , sender ) ;
1302
+ BaseRpcTarget target = null ;
1303
+ switch ( allocationType )
1304
+ {
1305
+ case AllocationType . Array :
1306
+ target = senderObject . RpcTarget . Group ( recipient , RpcTargetUse . Temp ) ;
1307
+ break ;
1308
+ case AllocationType . List :
1309
+ target = senderObject . RpcTarget . Group ( recipient . ToList ( ) , RpcTargetUse . Temp ) ;
1310
+ break ;
1311
+ case AllocationType . NativeArray :
1312
+ var arr = new NativeArray < ulong > ( recipient , Allocator . Temp ) ;
1313
+ target = senderObject . RpcTarget . Group ( arr , RpcTargetUse . Temp ) ;
1314
+ arr . Dispose ( ) ;
1315
+ break ;
1316
+ case AllocationType . NativeList :
1317
+ // For some reason on 2020.3, calling list.AsArray() and passing that to the next function
1318
+ // causes Allocator.Temp allocations to become invalid somehow. This is not an issue on later
1319
+ // versions of Unity.
1320
+ var list = new NativeList < ulong > ( recipient . Length , Allocator . TempJob ) ;
1321
+ foreach ( var id in recipient )
1301
1322
{
1302
- for ( ulong sender = 0u ; sender <= 2u ; ++ sender )
1303
- {
1304
- yield return waitFor ;
1305
- foreach ( var allocationType in Enum . GetValues ( typeof ( AllocationType ) ) )
1306
- {
1307
- //if (++YieldCheck % YieldCycleCount == 0)
1308
- //{
1309
- // yield return null;
1310
- //}
1311
- OnInlineSetup ( ) ;
1312
- var sendMethodName = $ "DefaultTo{ defaultSendTo } AllowOverrideRpc";
1313
-
1314
- var senderObject = GetPlayerObject ( objectOwner , sender ) ;
1315
- BaseRpcTarget target = null ;
1316
- switch ( allocationType )
1317
- {
1318
- case AllocationType . Array :
1319
- target = senderObject . RpcTarget . Group ( recipient , RpcTargetUse . Temp ) ;
1320
- break ;
1321
- case AllocationType . List :
1322
- target = senderObject . RpcTarget . Group ( recipient . ToList ( ) , RpcTargetUse . Temp ) ;
1323
- break ;
1324
- case AllocationType . NativeArray :
1325
- var arr = new NativeArray < ulong > ( recipient , Allocator . Temp ) ;
1326
- target = senderObject . RpcTarget . Group ( arr , RpcTargetUse . Temp ) ;
1327
- arr . Dispose ( ) ;
1328
- break ;
1329
- case AllocationType . NativeList :
1330
- // For some reason on 2020.3, calling list.AsArray() and passing that to the next function
1331
- // causes Allocator.Temp allocations to become invalid somehow. This is not an issue on later
1332
- // versions of Unity.
1333
- var list = new NativeList < ulong > ( recipient . Length , Allocator . TempJob ) ;
1334
- foreach ( var id in recipient )
1335
- {
1336
- list . Add ( id ) ;
1337
- }
1338
-
1339
- target = senderObject . RpcTarget . Group ( list , RpcTargetUse . Temp ) ;
1340
- list . Dispose ( ) ;
1341
- break ;
1342
- }
1343
-
1344
- var sendMethod = senderObject . GetType ( ) . GetMethod ( sendMethodName ) ;
1345
- sendMethod . Invoke ( senderObject , new object [ ] { ( RpcParams ) target } ) ;
1346
-
1347
- VerifyRemoteReceived ( objectOwner , sender , sendMethodName , s_ClientIds . Where ( c => recipient . Contains ( c ) ) . ToArray ( ) , false ) ;
1348
- VerifyNotReceived ( objectOwner , s_ClientIds . Where ( c => ! recipient . Contains ( c ) ) . ToArray ( ) ) ;
1349
-
1350
- // Pass some time to make sure that no other client ever receives this
1351
- TimeTravel ( 1f , 30 ) ;
1352
- VerifyNotReceived ( objectOwner , s_ClientIds . Where ( c => ! recipient . Contains ( c ) ) . ToArray ( ) ) ;
1353
- OnInlineTearDown ( ) ;
1354
- }
1355
- }
1323
+ list . Add ( id ) ;
1356
1324
}
1357
- }
1325
+ target = senderObject . RpcTarget . Group ( list , RpcTargetUse . Temp ) ;
1326
+ list . Dispose ( ) ;
1327
+ break ;
1358
1328
}
1329
+ var sendMethod = senderObject . GetType ( ) . GetMethod ( sendMethodName ) ;
1330
+ sendMethod . Invoke ( senderObject , new object [ ] { ( RpcParams ) target } ) ;
1331
+
1332
+ VerifyRemoteReceived ( objectOwner , sender , sendMethodName , s_ClientIds . Where ( c => recipient . Contains ( c ) ) . ToArray ( ) , false ) ;
1333
+ VerifyNotReceived ( objectOwner , s_ClientIds . Where ( c => ! recipient . Contains ( c ) ) . ToArray ( ) ) ;
1334
+
1335
+ // Pass some time to make sure that no other client ever receives this
1336
+ TimeTravel ( 1f , 30 ) ;
1337
+ VerifyNotReceived ( objectOwner , s_ClientIds . Where ( c => ! recipient . Contains ( c ) ) . ToArray ( ) ) ;
1359
1338
}
1360
1339
}
1361
1340
1341
+ [ Timeout ( 1200000 ) ]
1362
1342
[ TestFixture ( HostOrServer . Host ) ]
1363
1343
[ TestFixture ( HostOrServer . Server ) ]
1364
1344
internal class UniversalRpcTestSendingWithGroupNotOverride : UniversalRpcTestsBase
@@ -1384,78 +1364,56 @@ public enum AllocationType
1384
1364
List
1385
1365
}
1386
1366
1387
- [ UnityTest ]
1388
- public IEnumerator TestSendingWithGroupNotOverride ( )
1367
+ // Extending timeout since the added yield return causes this test to commonly timeout
1368
+ [ Test ]
1369
+ public void TestSendingWithGroupNotOverride (
1370
+ [ Values ] SendTo defaultSendTo ,
1371
+ [ ValueSource ( nameof ( RecipientGroups ) ) ] ulong [ ] recipient ,
1372
+ [ Values ( 0u , 1u , 2u ) ] ulong objectOwner ,
1373
+ [ Values ( 0u , 1u , 2u ) ] ulong sender ,
1374
+ [ Values ] AllocationType allocationType
1375
+ )
1389
1376
{
1390
- var waitFor = new WaitForFixedUpdate ( ) ;
1391
- foreach ( var defaultSendTo in Enum . GetValues ( typeof ( SendTo ) ) )
1377
+ var sendMethodName = $ "DefaultTo{ defaultSendTo } AllowOverrideRpc";
1378
+
1379
+ var senderObject = GetPlayerObject ( objectOwner , sender ) ;
1380
+ BaseRpcTarget target = null ;
1381
+ switch ( allocationType )
1392
1382
{
1393
- m_EnableVerboseDebug = true ;
1394
- VerboseDebug ( $ "Processing: { defaultSendTo } ") ;
1395
- m_EnableVerboseDebug = false ;
1396
- foreach ( var recipient in RecipientGroups )
1397
- {
1398
- for ( ulong objectOwner = 0u ; objectOwner <= 2u ; ++ objectOwner )
1383
+ case AllocationType . Array :
1384
+ target = senderObject . RpcTarget . Not ( recipient , RpcTargetUse . Temp ) ;
1385
+ break ;
1386
+ case AllocationType . List :
1387
+ target = senderObject . RpcTarget . Not ( recipient . ToList ( ) , RpcTargetUse . Temp ) ;
1388
+ break ;
1389
+ case AllocationType . NativeArray :
1390
+ var arr = new NativeArray < ulong > ( recipient , Allocator . Temp ) ;
1391
+ target = senderObject . RpcTarget . Not ( arr , RpcTargetUse . Temp ) ;
1392
+ arr . Dispose ( ) ;
1393
+ break ;
1394
+ case AllocationType . NativeList :
1395
+ // For some reason on 2020.3, calling list.AsArray() and passing that to the next function
1396
+ // causes Allocator.Temp allocations to become invalid somehow. This is not an issue on later
1397
+ // versions of Unity.
1398
+ var list = new NativeList < ulong > ( recipient . Length , Allocator . TempJob ) ;
1399
+ foreach ( var id in recipient )
1399
1400
{
1400
- for ( ulong sender = 0u ; sender <= 2u ; ++ sender )
1401
- {
1402
- yield return waitFor ;
1403
-
1404
- foreach ( var allocationType in Enum . GetValues ( typeof ( AllocationType ) ) )
1405
- {
1406
- //if (++YieldCheck % YieldCycleCount == 0)
1407
- //{
1408
- // yield return waitFor;
1409
- //}
1410
-
1411
- OnInlineSetup ( ) ;
1412
- var sendMethodName = $ "DefaultTo{ defaultSendTo } AllowOverrideRpc";
1413
-
1414
- var senderObject = GetPlayerObject ( objectOwner , sender ) ;
1415
- BaseRpcTarget target = null ;
1416
- switch ( allocationType )
1417
- {
1418
- case AllocationType . Array :
1419
- target = senderObject . RpcTarget . Not ( recipient , RpcTargetUse . Temp ) ;
1420
- break ;
1421
- case AllocationType . List :
1422
- target = senderObject . RpcTarget . Not ( recipient . ToList ( ) , RpcTargetUse . Temp ) ;
1423
- break ;
1424
- case AllocationType . NativeArray :
1425
- var arr = new NativeArray < ulong > ( recipient , Allocator . Temp ) ;
1426
- target = senderObject . RpcTarget . Not ( arr , RpcTargetUse . Temp ) ;
1427
- arr . Dispose ( ) ;
1428
- break ;
1429
- case AllocationType . NativeList :
1430
- // For some reason on 2020.3, calling list.AsArray() and passing that to the next function
1431
- // causes Allocator.Temp allocations to become invalid somehow. This is not an issue on later
1432
- // versions of Unity.
1433
- var list = new NativeList < ulong > ( recipient . Length , Allocator . TempJob ) ;
1434
- foreach ( var id in recipient )
1435
- {
1436
- list . Add ( id ) ;
1437
- }
1438
- target = senderObject . RpcTarget . Not ( list , RpcTargetUse . Temp ) ;
1439
- list . Dispose ( ) ;
1440
- break ;
1441
- }
1442
- var sendMethod = senderObject . GetType ( ) . GetMethod ( sendMethodName ) ;
1443
- sendMethod . Invoke ( senderObject , new object [ ] { ( RpcParams ) target } ) ;
1444
-
1445
- VerifyRemoteReceived ( objectOwner , sender , sendMethodName , s_ClientIds . Where ( c => ! recipient . Contains ( c ) ) . ToArray ( ) , false ) ;
1446
- VerifyNotReceived ( objectOwner , s_ClientIds . Where ( c => recipient . Contains ( c ) ) . ToArray ( ) ) ;
1447
-
1448
- // Pass some time to make sure that no other client ever receives this
1449
- TimeTravel ( 1f , 30 ) ;
1450
- VerifyNotReceived ( objectOwner , s_ClientIds . Where ( c => recipient . Contains ( c ) ) . ToArray ( ) ) ;
1451
- OnInlineTearDown ( ) ;
1452
- }
1453
- }
1401
+ list . Add ( id ) ;
1454
1402
}
1455
- }
1403
+ target = senderObject . RpcTarget . Not ( list , RpcTargetUse . Temp ) ;
1404
+ list . Dispose ( ) ;
1405
+ break ;
1456
1406
}
1457
- }
1407
+ var sendMethod = senderObject . GetType ( ) . GetMethod ( sendMethodName ) ;
1408
+ sendMethod . Invoke ( senderObject , new object [ ] { ( RpcParams ) target } ) ;
1409
+
1410
+ VerifyRemoteReceived ( objectOwner , sender , sendMethodName , s_ClientIds . Where ( c => ! recipient . Contains ( c ) ) . ToArray ( ) , false ) ;
1411
+ VerifyNotReceived ( objectOwner , s_ClientIds . Where ( c => recipient . Contains ( c ) ) . ToArray ( ) ) ;
1458
1412
1413
+ // Pass some time to make sure that no other client ever receives this
1414
+ TimeTravel ( 1f , 30 ) ;
1415
+ VerifyNotReceived ( objectOwner , s_ClientIds . Where ( c => recipient . Contains ( c ) ) . ToArray ( ) ) ;
1416
+ }
1459
1417
}
1460
1418
1461
1419
[ TestFixture ( HostOrServer . Host ) ]
0 commit comments