mirror of
https://github.com/sbrow/ps.git
synced 2026-02-28 03:01:43 -05:00
Added functionality
lib - Save - DoAction - ApplyDataset - GetLayer(s) main - do actions from commandline Improved test cases!
This commit is contained in:
95
ps_test.go
95
ps_test.go
@@ -2,6 +2,7 @@ package ps
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// "log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
_ "strings"
|
||||
@@ -15,16 +16,44 @@ func TestPkgPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStart(t *testing.T) {
|
||||
Start()
|
||||
}
|
||||
|
||||
func TestOpen(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping \"TestOpen\"")
|
||||
}
|
||||
_, err := Open("F:\\GitLab\\dreamkeepers-psd\\Template009.1.psd")
|
||||
err := Open("F:\\GitLab\\dreamkeepers-psd\\Template009.1.psd")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClose(t *testing.T) {
|
||||
Close()
|
||||
}
|
||||
|
||||
func TestQuit(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping \"TestQuit\"")
|
||||
}
|
||||
Quit(2)
|
||||
}
|
||||
|
||||
func TestDoJs(t *testing.T) {
|
||||
out := []byte("F:\\TEMP\\js_out.txt\r\narg\r\nargs\r\n")
|
||||
script := "test.jsx"
|
||||
ret, err := DoJs(script, "arg", "args")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(ret) != string(out) {
|
||||
fail := fmt.Sprintf("TestJS failed.\ngot:\t\"%s\"\nwant:\t\"%s\"", ret, out)
|
||||
t.Fatal(fail)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
out := []byte("hello,\r\nworld!\r\n")
|
||||
msg, err := run("test", "hello,", "world!")
|
||||
@@ -37,22 +66,62 @@ func TestRun(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQuit(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("Skipping \"TestQuit\"")
|
||||
}
|
||||
Quit(2)
|
||||
}
|
||||
|
||||
func TestWait(t *testing.T) {
|
||||
Wait("Waiting...")
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func TestJS(t *testing.T) {
|
||||
out := []byte("F:\\TEMP\\js_out.txt\r\narg\r\nargs\r\n")
|
||||
script := "test.jsx"
|
||||
ret, err := Js(script, "arg", "args")
|
||||
func TestDoAction_Crop(t *testing.T) {
|
||||
err := Open("F:\\GitLab\\dreamkeepers-psd\\Template009.1.psd")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = DoAction("DK", "Crop")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDoAction_Undo(t *testing.T) {
|
||||
err := DoAction("DK", "Undo")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSaveAs(t *testing.T) {
|
||||
err := SaveAs("F:\\TEMP\\test.png")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLayers(t *testing.T) {
|
||||
byt, err := Layers("Areas/TitleBackground")
|
||||
// _, err := Layers("Areas/TitleBackground")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, lyr := range byt {
|
||||
fmt.Println(lyr.Name)
|
||||
fmt.Println(lyr.Bounds)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestLayer(t *testing.T) {
|
||||
// lyr, err := Layer("Areas/TitleBackground")
|
||||
_, err := Layer("Areas/TitleBackground")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
/* fmt.Println(lyr.Name)
|
||||
fmt.Println(lyr.Bounds)
|
||||
*/
|
||||
}
|
||||
|
||||
func TestApplyDataset(t *testing.T) {
|
||||
out := []byte("done!\r\n")
|
||||
ret, err := ApplyDataset("Anger")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user