@@ -87,6 +87,76 @@ public void singleServiceAndWindowDefinition() throws Exception {
8787 assertThat (getOnlyCue (firstSubtitle ).text .toString ()).isEqualTo ("test subtitle" );
8888 }
8989
90+ @ Test
91+ public void setPenLocationTestWithNewLineTest1 () throws Exception {
92+ Cea708Decoder cea708Decoder =
93+ new Cea708Decoder (
94+
95+ /* accessibilityChannel= */ Format .NO_VALUE , /* initializationData= */ null );
96+ byte [] windowDefinition =
97+ TestUtil .createByteArray (
98+ 0x98 , // DF0 command (define window 0)
99+ 0b0010_0000, // visible=true, row lock and column lock disabled, priority=0
100+ 0xF0 | 50 , // relative positioning, anchor vertical
101+ 50 , // anchor horizontal
102+ 10 , // anchor point = 0, row count = 10
103+ 30 , // column count = 30
104+ 0b0000_1001); // window style = 1, pen style = 1
105+ byte [] setCurrentWindow = TestUtil .createByteArray (0x80 ); // CW0 (set current window to 0)
106+ byte [] setPenLocation = TestUtil .createByteArray (0x92 ,0x01 ,0x00 ); // COMMAND_SPL with row 1 and
107+ byte [] newLine = TestUtil .createByteArray (0x0D ); // new line
108+ byte [] subtitleData =
109+ encodePacketIntoBytePairs (
110+ createPacket (
111+ /* sequenceNumber= */ 0 ,
112+ createServiceBlock (
113+ Bytes .concat (
114+ windowDefinition ,
115+ setCurrentWindow ,
116+ "line1" .getBytes (Charsets .UTF_8 ),
117+ newLine ,
118+ setPenLocation ,
119+ "line2" .getBytes (Charsets .UTF_8 )))));
120+
121+ Subtitle firstSubtitle = decodeSampleAndCopyResult (cea708Decoder , subtitleData );
122+
123+ assertThat (getOnlyCue (firstSubtitle ).text .toString ()).isEqualTo ("line1\n line2" );
124+ }
125+
126+ @ Test
127+ public void setPenLocationTestWithNewLineTest2 () throws Exception {
128+ Cea708Decoder cea708Decoder =
129+ new Cea708Decoder (
130+
131+ /* accessibilityChannel= */ Format .NO_VALUE , /* initializationData= */ null );
132+ byte [] windowDefinition =
133+ TestUtil .createByteArray (
134+ 0x98 , // DF0 command (define window 0)
135+ 0b0010_0000, // visible=true, row lock and column lock disabled, priority=0
136+ 0xF0 | 50 , // relative positioning, anchor vertical
137+ 50 , // anchor horizontal
138+ 10 , // anchor point = 0, row count = 10
139+ 30 , // column count = 30
140+ 0b0000_1001); // window style = 1, pen style = 1
141+ byte [] setCurrentWindow = TestUtil .createByteArray (0x80 ); // CW0 (set current window to 0)
142+ byte [] setPenLocation = TestUtil .createByteArray (0x92 ,0x01 ,0x00 ); // COMMAND_SPL with row 1 and
143+ byte [] subtitleData =
144+ encodePacketIntoBytePairs (
145+ createPacket (
146+ /* sequenceNumber= */ 0 ,
147+ createServiceBlock (
148+ Bytes .concat (
149+ windowDefinition ,
150+ setCurrentWindow ,
151+ "line1" .getBytes (Charsets .UTF_8 ),
152+ setPenLocation ,
153+ "line2" .getBytes (Charsets .UTF_8 )))));
154+
155+ Subtitle firstSubtitle = decodeSampleAndCopyResult (cea708Decoder , subtitleData );
156+
157+ assertThat (getOnlyCue (firstSubtitle ).text .toString ()).isEqualTo ("line1\n line2" );
158+ }
159+
90160 /**
91161 * Queues {@code sample} to {@code decoder} and dequeues the result, then copies and returns it if
92162 * it's non-null.
0 commit comments