Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clipboard operations: xclip or pbcopy/pbpaste style operations.
- Loading branch information
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
amm/repl/src/test/scala/ammonite/unit/ClipboardTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package ammonite.unit | ||
|
||
import ammonite.repl.{Clipboard, ClipboardImpl} | ||
|
||
import java.awt.Toolkit | ||
import java.awt.datatransfer.DataFlavor | ||
|
||
import utest._ | ||
|
||
object ClipboardTests extends TestSuite{ | ||
|
||
val clipboard: Clipboard = ClipboardImpl | ||
|
||
val canTest = Toolkit.getDefaultToolkit.getSystemClipboard.isDataFlavorAvailable( | ||
DataFlavor.stringFlavor | ||
) | ||
|
||
override def tests = Tests { | ||
println("ClipboardTests") | ||
'clipboard { | ||
val newClipboardContents = "hello Ammonite" | ||
'copyandpaste - { | ||
if (canTest) { | ||
clipboard.write(newClipboardContents) | ||
assert(clipboard.read == newClipboardContents) | ||
} else { | ||
println("The environment doesn't allow testing clipboard operations - skipping") | ||
} | ||
} | ||
} | ||
} | ||
} |