2020-11-23 08:15:19 +00:00
|
|
|
package cwclient
|
2020-11-20 10:47:16 +00:00
|
|
|
|
|
|
|
import (
|
2020-11-24 11:54:23 +00:00
|
|
|
"encoding/json"
|
2020-11-20 10:47:16 +00:00
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPort(t *testing.T) {
|
|
|
|
cli := New("http://localhost:7123")
|
2020-11-23 10:49:37 +00:00
|
|
|
|
2020-11-24 11:54:23 +00:00
|
|
|
ltest := cli.Register("test", func(cxt *CallbackContext) {
|
|
|
|
if cxt.Error != nil {
|
|
|
|
log.Println("error:", cxt.Error)
|
2020-11-24 07:17:56 +00:00
|
|
|
} else {
|
2020-11-24 11:54:23 +00:00
|
|
|
log.Println(cxt.TaskID, cxt.Content, cxt.Carry)
|
2020-11-24 07:17:56 +00:00
|
|
|
}
|
2020-11-20 10:47:16 +00:00
|
|
|
})
|
2020-11-25 04:25:19 +00:00
|
|
|
|
2020-11-23 10:49:37 +00:00
|
|
|
ltest.SetContentConditionFromFile("example.js")
|
2020-11-20 10:47:16 +00:00
|
|
|
cli.Connect()
|
2020-11-25 08:33:15 +00:00
|
|
|
log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser", nil))
|
2020-11-25 04:25:19 +00:00
|
|
|
// log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/yanngu?lang=en&deviceType=browser", "213"))
|
2020-11-24 11:54:23 +00:00
|
|
|
// log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser"))
|
|
|
|
// log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/yanngu?lang=en&deviceType=browser"))
|
2020-11-25 04:25:19 +00:00
|
|
|
http.ListenAndServe(":4233", nil)
|
2020-11-20 10:47:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestChrome(t *testing.T) {
|
|
|
|
|
2020-11-24 11:54:23 +00:00
|
|
|
var a = make(map[string]interface{})
|
|
|
|
a["as"] = 123
|
|
|
|
data, _ := json.Marshal(a["as"])
|
|
|
|
log.Println(string(data), a["as"])
|
2020-11-20 10:47:16 +00:00
|
|
|
}
|