|
|
@ -130,12 +130,12 @@ class ClipboardUtilsTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest
|
|
|
|
@ParameterizedTest
|
|
|
|
@MethodSource("provideArgumentsForRetrievingClipboardContents")
|
|
|
|
@MethodSource("provideArgumentsForRetrievingGenericClipboardContents")
|
|
|
|
void successfullyRetrieveOldClipboardContents(GenericClipboardContent<?> expectedGenericClipboardContent, Object expectedContent, DataFlavor dataFlavor) throws IOException, UnsupportedFlavorException {
|
|
|
|
void successfullyRetrieveOldClipboardContents(GenericClipboardContent<?> expectedGenericClipboardContent, Object expectedContent, DataFlavor dataFlavor) throws IOException, UnsupportedFlavorException {
|
|
|
|
when(transferableMock.isDataFlavorSupported(dataFlavor)).thenReturn(true);
|
|
|
|
when(transferableMock.isDataFlavorSupported(dataFlavor)).thenReturn(true);
|
|
|
|
when(transferableMock.getTransferData(dataFlavor)).thenReturn(expectedContent);
|
|
|
|
when(transferableMock.getTransferData(dataFlavor)).thenReturn(expectedContent);
|
|
|
|
|
|
|
|
|
|
|
|
GenericClipboardContent<?> actualGenericClipboardContent = sut.getClipboardContents(transferableMock);
|
|
|
|
GenericClipboardContent<?> actualGenericClipboardContent = sut.getGenericClipboardContents(transferableMock);
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(actualGenericClipboardContent.getOldContent(), is(expectedGenericClipboardContent.getOldContent()));
|
|
|
|
assertThat(actualGenericClipboardContent.getOldContent(), is(expectedGenericClipboardContent.getOldContent()));
|
|
|
|
verifyNoInteractions(logger);
|
|
|
|
verifyNoInteractions(logger);
|
|
|
@ -147,7 +147,7 @@ class ClipboardUtilsTest {
|
|
|
|
when(transferableMock.isDataFlavorSupported(dataFlavor)).thenReturn(true);
|
|
|
|
when(transferableMock.isDataFlavorSupported(dataFlavor)).thenReturn(true);
|
|
|
|
when(transferableMock.getTransferData(dataFlavor)).thenReturn(expectedContent);
|
|
|
|
when(transferableMock.getTransferData(dataFlavor)).thenReturn(expectedContent);
|
|
|
|
|
|
|
|
|
|
|
|
ClipboardContent actualClipboardContent = sut.getOldClipboardContent(transferableMock);
|
|
|
|
ClipboardContent actualClipboardContent = sut.getClipboardContent(transferableMock);
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(actualClipboardContent.getText(), is(expectedString));
|
|
|
|
assertThat(actualClipboardContent.getText(), is(expectedString));
|
|
|
|
assertThat(actualClipboardContent.getFiles(), is(expectedFiles));
|
|
|
|
assertThat(actualClipboardContent.getFiles(), is(expectedFiles));
|
|
|
@ -158,7 +158,7 @@ class ClipboardUtilsTest {
|
|
|
|
@ParameterizedTest
|
|
|
|
@ParameterizedTest
|
|
|
|
@MethodSource("provideArgumentsForOldClipboardContents")
|
|
|
|
@MethodSource("provideArgumentsForOldClipboardContents")
|
|
|
|
void successfullyMarshallClipboardContentsIntoOldClipboardContent(Object expectedOldContent, String expectedString, BufferedImage expectedImage, List<File> expectedFiles) {
|
|
|
|
void successfullyMarshallClipboardContentsIntoOldClipboardContent(Object expectedOldContent, String expectedString, BufferedImage expectedImage, List<File> expectedFiles) {
|
|
|
|
ClipboardContent actualClipboardContent = sut.getOldClipboardContent(expectedOldContent);
|
|
|
|
ClipboardContent actualClipboardContent = sut.getClipboardContent(expectedOldContent);
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(actualClipboardContent.getText(), is(expectedString));
|
|
|
|
assertThat(actualClipboardContent.getText(), is(expectedString));
|
|
|
|
assertThat(actualClipboardContent.getImage(), is(expectedImage));
|
|
|
|
assertThat(actualClipboardContent.getImage(), is(expectedImage));
|
|
|
@ -192,7 +192,7 @@ class ClipboardUtilsTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Stream<Arguments> provideArgumentsForRetrievingClipboardContents() {
|
|
|
|
static Stream<Arguments> provideArgumentsForRetrievingGenericClipboardContents() {
|
|
|
|
String string = "testString";
|
|
|
|
String string = "testString";
|
|
|
|
BufferedImage bufferedImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
|
|
|
|
BufferedImage bufferedImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
|
|
|
|
MyBufferedImage myBufferedImage = new MyBufferedImage(bufferedImage);
|
|
|
|
MyBufferedImage myBufferedImage = new MyBufferedImage(bufferedImage);
|
|
|
|