@@ -642,17 +642,90 @@ TEST_CASE("Auto Optimizer client preserves saved Dual Format estimates without m
642642 CHECK (projected[" videos" ][1 ] == vertical);
643643 CHECK_FALSE (projected.contains (" encoding" ));
644644 checkInvalidResultMutations (
645- fixture, {{" changed saved vertical size" ,
646- [](json &value) {
647- value[" legs" ][0 ][" recommendation" ][" additionalVideo" ][" width" ] = 1080 ;
648- value[" legs" ][0 ][" recommendation" ][" additionalVideo" ][" height" ] = 1920 ;
649- }},
645+ fixture, {{" unmeasured vertical promotion" , [](json &value) { value[" legs" ][0 ][" recommendation" ][" additionalVideo" ][" width" ] = 1442 ; }},
650646 {" changed saved vertical cadence" , [](json &value) { value[" legs" ][0 ][" recommendation" ][" additionalVideo" ][" fpsNum" ] = 60 ; }},
651647 {" unmeasured primary promotion" , [](json &value) { value[" legs" ][0 ][" recommendation" ][" fpsNum" ] = 120 ; }}});
652648 auto limited = prepared.context ;
653649 limited.outputs [0 ].additionalVideo ->limits .maxWidth = 1080 ;
654650 limited.outputs [0 ].additionalVideo ->limits .maxHeight = 1920 ;
655651 CHECK_FALSE (contract::projectResult (fixture.result .dump (), " run" , limited).valid );
652+ fixture.result [" legs" ][0 ][" recommendation" ][" additionalVideo" ][" width" ] = 1080 ;
653+ fixture.result [" legs" ][0 ][" recommendation" ][" additionalVideo" ][" height" ] = 1920 ;
654+ CHECK (contract::projectResult (fixture.result .dump (), " run" , limited).valid );
655+ }
656+
657+ TEST_CASE (" Auto Optimizer client requires exact measured proof for independently shaped Dual Format outputs" )
658+ {
659+ json output = enhancedBroadcastingOutput ();
660+ output[" current" ] = current (3440 , 1440 , 6000 , 1 );
661+ output[" limits" ] = {{" maxWidth" , 1920 }, {" maxHeight" , 1080 }};
662+ const auto prepared = prepare ({{" streamSetup" , " enhanced-broadcasting" }, {" outputs" , json::array ({output})}});
663+ json returned = returnedEnhancedBroadcastingOutput ();
664+ returned[" recommendation" ][" height" ] = 802 ;
665+ returned[" measurement" ][" probes" ][0 ][" testedHeight" ] = 802 ;
666+ ResultFixture fixture{prepared, {{" schemaVersion" , 1 }, {" sessionId" , " run" }, {" status" , " complete" }, {" legs" , json::array ({returned})}}};
667+ REQUIRE (contract::projectResult (fixture.result .dump (), " run" , prepared.context ).valid );
668+ checkInvalidResultMutations (
669+ fixture, {
670+ {" unproven custom primary" , [](json &value) { value[" legs" ][0 ][" measurement" ][" probes" ][0 ][" testedHeight" ] = 1080 ; }},
671+ {" rotated ultrawide must not replace vertical output" ,
672+ [](json &value) {
673+ auto &leg = value[" legs" ][0 ];
674+ leg[" recommendation" ][" additionalVideo" ][" width" ] = 802 ;
675+ leg[" measurement" ][" probes" ][0 ][" testedAdditionalVideo" ] = leg[" recommendation" ][" additionalVideo" ];
676+ }},
677+ });
678+ }
679+
680+ TEST_CASE (" Auto Optimizer client caps custom Dual Format validation to Twitch limits" )
681+ {
682+ struct Example {
683+ int width, height, maxWidth, maxHeight, expectedWidth, expectedHeight;
684+ };
685+ const auto example = GENERATE (Example{1200 , 1600 , 1200 , 1600 , 1080 , 1440 }, Example{1000 , 2400 , 1000 , 2400 , 800 , 1920 },
686+ Example{1200 , 1600 , 720 , 1280 , 720 , 960 }, Example{1200 , 1600 , 1080 , 1920 , 1080 , 1440 },
687+ Example{1200 , 1600 , 0 , 0 , 1080 , 1440 });
688+ CAPTURE (example.width , example.height , example.maxWidth , example.maxHeight );
689+ json output = enhancedBroadcastingOutput ();
690+ output[" additionalVideo" ][" current" ] = current (example.width , example.height , 6000 , 2 );
691+ if (example.maxWidth )
692+ output[" additionalVideo" ][" limits" ] = {{" maxWidth" , example.maxWidth }, {" maxHeight" , example.maxHeight }};
693+ const auto prepared = prepare ({{" streamSetup" , " enhanced-broadcasting" }, {" outputs" , json::array ({output})}});
694+ json returned = returnedEnhancedBroadcastingOutput ();
695+ auto &additional = returned[" recommendation" ][" additionalVideo" ];
696+ additional[" width" ] = example.expectedWidth ;
697+ additional[" height" ] = example.expectedHeight ;
698+ returned[" measurement" ][" probes" ][0 ][" testedAdditionalVideo" ] = additional;
699+ ResultFixture fixture{prepared, {{" schemaVersion" , 1 }, {" sessionId" , " run" }, {" status" , " complete" }, {" legs" , json::array ({returned})}}};
700+ const auto projected = contract::projectResult (fixture.result .dump (), " run" , prepared.context );
701+ REQUIRE (projected.valid );
702+ CHECK (json::parse (projected.json )[" outputs" ][0 ][" videos" ][1 ] == additional);
703+ checkInvalidResultMutations (fixture, {{" mismatched measured vertical dimensions" ,
704+ [](json &value) { value[" legs" ][0 ][" measurement" ][" probes" ][0 ][" testedAdditionalVideo" ][" width" ] = 2 ; }},
705+ {" uncapped vertical result despite matching proof" , [&](json &value) {
706+ auto &leg = value[" legs" ][0 ];
707+ auto &video = leg[" recommendation" ][" additionalVideo" ];
708+ video[" width" ] = example.width ;
709+ video[" height" ] = example.height ;
710+ leg[" measurement" ][" probes" ][0 ][" testedAdditionalVideo" ] = video;
711+ }}});
712+ }
713+
714+ TEST_CASE (" Auto Optimizer client accepts bounded ultrawide results but rejects oversized active and estimated tuples" )
715+ {
716+ const int width = GENERATE (3340 , 3440 );
717+ const bool measured = GENERATE (false , true );
718+ json output = standardOutput (" primary" , " horizontal" , " twitch" , twitchProbe ());
719+ output[" current" ] = current (width, 1440 , 6000 );
720+ const auto prepared = prepare ({{" streamSetup" , " direct-single" }, {" outputs" , json::array ({output})}});
721+ json returned = returnedStandardOutput (" primary" , " horizontal" , " twitch" , " twitch" , " twitch-bandwidth-test" , 6000 , 6000 );
722+ returned[" recommendation" ] = recommendation (1920 , width == 3440 ? 802 : 826 , 6000 );
723+ returned[" measurement" ][" mode" ] = measured ? " active" : " estimated" ;
724+ returned[" measurement" ][" probes" ][0 ][" success" ] = measured;
725+ json result = {{" schemaVersion" , 1 }, {" sessionId" , " run" }, {" status" , " complete" }, {" legs" , json::array ({returned})}};
726+ CHECK (contract::projectResult (result.dump (), " run" , prepared.context ).valid );
727+ result[" legs" ][0 ][" recommendation" ] = recommendation (width, 1440 , 6000 );
728+ CHECK_FALSE (contract::projectResult (result.dump (), " run" , prepared.context ).valid );
656729}
657730
658731TEST_CASE (" Auto Optimizer client preserves measured Enhanced Broadcasting fallback explanations" )
0 commit comments