@@ -427,4 +427,50 @@ public void testGetCommentsFormatting() throws IOException, ExtractionException
427427 assertContains ("<b>" , firstComment .getCommentText ().getContent ());
428428 }
429429 }
430+
431+ /**
432+ * Test live chat mode behavior on a regular video extractor.
433+ * Does not extend {@link Base} because these tests do not need network/mock data.
434+ */
435+ public static class LiveChatMode {
436+ private static final String URL = "https://www.youtube.com/watch?v=D00Au7k3i6o" ;
437+
438+ @ org .junit .jupiter .api .BeforeAll
439+ static void setUp () {
440+ org .schabi .newpipe .extractor .InitNewPipeTest .initEmpty ();
441+ org .schabi .newpipe .extractor .NewPipe .init (new org .schabi .newpipe .extractor .downloader .Downloader () {
442+ @ org .jetbrains .annotations .NotNull
443+ @ Override
444+ public org .schabi .newpipe .extractor .downloader .Response execute (
445+ @ org .jetbrains .annotations .NotNull final org .schabi .newpipe .extractor .downloader .Request request ) {
446+ throw new UnsupportedOperationException ("No communication expected" );
447+ }
448+ });
449+ }
450+
451+ private YoutubeCommentsExtractor createExtractor () throws Exception {
452+ return (YoutubeCommentsExtractor ) YouTube .getCommentsExtractor (URL );
453+ }
454+
455+ @ Test
456+ void testIsLiveChatDefaultFalse () throws Exception {
457+ assertFalse (createExtractor ().isLiveChat ());
458+ }
459+
460+ @ Test
461+ void testSetLiveChatContinuationActivatesLiveChat () throws Exception {
462+ final YoutubeCommentsExtractor extractor = createExtractor ();
463+ assertFalse (extractor .isLiveChat ());
464+ extractor .setLiveChatContinuation ("test-continuation" );
465+ assertTrue (extractor .isLiveChat ());
466+ }
467+
468+ @ Test
469+ void testCommentsDisabledIsFalseInLiveChatMode () throws Exception {
470+ final YoutubeCommentsExtractor extractor = createExtractor ();
471+ extractor .setLiveChatContinuation ("test-continuation" );
472+ assertTrue (extractor .isLiveChat ());
473+ assertFalse (extractor .isCommentsDisabled ());
474+ }
475+ }
430476}
0 commit comments