@@ -376,16 +376,16 @@ test("screen sharing activates spotlight layout", () => {
376
376
377
377
test ( "participants stay in the same order unless to appear/disappear" , ( ) => {
378
378
withTestScheduler ( ( { hot, schedule, expectObservable } ) => {
379
- const modeInputMarbles = " a" ;
379
+ const visibilityInputMarbles = "a" ;
380
380
// First Bob speaks, then Dave, then Alice
381
- const aSpeakingInputMarbles = "n- 1998ms - 1999ms y" ;
382
- const bSpeakingInputMarbles = "ny 1998ms n 1999ms -" ;
383
- const dSpeakingInputMarbles = "n- 1998ms y 1999ms n" ;
381
+ const aSpeakingInputMarbles = " n- 1998ms - 1999ms y" ;
382
+ const bSpeakingInputMarbles = " ny 1998ms n 1999ms -" ;
383
+ const dSpeakingInputMarbles = " n- 1998ms y 1999ms n" ;
384
384
// Nothing should change when Bob speaks, because Bob is already on screen.
385
385
// When Dave speaks he should switch with Alice because she's the one who
386
386
// hasn't spoken at all. Then when Alice speaks, she should return to her
387
387
// place at the top.
388
- const expectedLayoutMarbles = "a 1999ms b 1999ms a 57999ms c 1999ms a" ;
388
+ const expectedLayoutMarbles = " a 1999ms b 1999ms a 57999ms c 1999ms a" ;
389
389
390
390
withCallViewModel (
391
391
of ( [ aliceParticipant , bobParticipant , daveParticipant ] ) ,
@@ -397,7 +397,7 @@ test("participants stay in the same order unless to appear/disappear", () => {
397
397
[ daveParticipant , hot ( dSpeakingInputMarbles , { y : true , n : false } ) ] ,
398
398
] ) ,
399
399
( vm ) => {
400
- schedule ( modeInputMarbles , {
400
+ schedule ( visibilityInputMarbles , {
401
401
a : ( ) => {
402
402
// We imagine that only three tiles (the first three) will be visible
403
403
// on screen at a time
@@ -432,6 +432,56 @@ test("participants stay in the same order unless to appear/disappear", () => {
432
432
} ) ;
433
433
} ) ;
434
434
435
+ test ( "participants adjust order when space becomes constrained" , ( ) => {
436
+ withTestScheduler ( ( { hot, schedule, expectObservable } ) => {
437
+ // Start with all tiles on screen then shrink to 3
438
+ const visibilityInputMarbles = "a-b" ;
439
+ // Bob and Dave speak
440
+ const bSpeakingInputMarbles = " ny" ;
441
+ const dSpeakingInputMarbles = " ny" ;
442
+ // Nothing should change when Bob or Dave initially speak, because they are
443
+ // on screen. When the screen becomes smaller Alice should move off screen
444
+ // to make way for the speakers (specifically, she should swap with Dave).
445
+ const expectedLayoutMarbles = " a-b" ;
446
+
447
+ withCallViewModel (
448
+ of ( [ aliceParticipant , bobParticipant , daveParticipant ] ) ,
449
+ of ( [ aliceRtcMember , bobRtcMember , daveRtcMember ] ) ,
450
+ of ( ConnectionState . Connected ) ,
451
+ new Map ( [
452
+ [ bobParticipant , hot ( bSpeakingInputMarbles , { y : true , n : false } ) ] ,
453
+ [ daveParticipant , hot ( dSpeakingInputMarbles , { y : true , n : false } ) ] ,
454
+ ] ) ,
455
+ ( vm ) => {
456
+ let setVisibleTiles : ( ( value : number ) => void ) | null = null ;
457
+ vm . layout . subscribe ( ( layout ) => {
458
+ if ( layout . type === "grid" ) setVisibleTiles = layout . setVisibleTiles ;
459
+ } ) ;
460
+ schedule ( visibilityInputMarbles , {
461
+ a : ( ) => setVisibleTiles ! ( Infinity ) ,
462
+ b : ( ) => setVisibleTiles ! ( 3 ) ,
463
+ } ) ;
464
+
465
+ expectObservable ( summarizeLayout ( vm . layout ) ) . toBe (
466
+ expectedLayoutMarbles ,
467
+ {
468
+ a : {
469
+ type : "grid" ,
470
+ spotlight : undefined ,
471
+ grid : [ "local:0" , `${ aliceId } :0` , `${ bobId } :0` , `${ daveId } :0` ] ,
472
+ } ,
473
+ b : {
474
+ type : "grid" ,
475
+ spotlight : undefined ,
476
+ grid : [ "local:0" , `${ daveId } :0` , `${ bobId } :0` , `${ aliceId } :0` ] ,
477
+ } ,
478
+ } ,
479
+ ) ;
480
+ } ,
481
+ ) ;
482
+ } ) ;
483
+ } ) ;
484
+
435
485
test ( "spotlight speakers swap places" , ( ) => {
436
486
withTestScheduler ( ( { hot, schedule, expectObservable } ) => {
437
487
// Go immediately into spotlight mode for the test
0 commit comments