Skip to content

Commit

Permalink
Add unit test for big "set clipboard" event
Browse files Browse the repository at this point in the history
Add a unit test to avoid regressions.

Refs #1425 <#1425>
  • Loading branch information
rom1v committed May 24, 2020
1 parent 517dbd9 commit c7155a1
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ public void testParseSetClipboardEvent() throws IOException {
Assert.assertEquals("testé", event.getText());
}

@Test
public void testParseBigSetClipboardEvent() throws IOException {
ControlMessageReader reader = new ControlMessageReader();

ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeByte(ControlMessage.TYPE_SET_CLIPBOARD);

byte[] rawText = new byte[ControlMessageReader.CLIPBOARD_TEXT_MAX_LENGTH];
Arrays.fill(rawText, (byte) 'a');
String text = new String(rawText, 0, rawText.length);

dos.writeShort(rawText.length);
dos.write(rawText);

byte[] packet = bos.toByteArray();

reader.readFrom(new ByteArrayInputStream(packet));
ControlMessage event = reader.next();

Assert.assertEquals(ControlMessage.TYPE_SET_CLIPBOARD, event.getType());
Assert.assertEquals(text, event.getText());
}

@Test
public void testParseSetScreenPowerMode() throws IOException {
ControlMessageReader reader = new ControlMessageReader();
Expand Down

0 comments on commit c7155a1

Please sign in to comment.