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-23 10:49:37 +00:00
|
|
|
ltest.SetContentConditionFromFile("example.js")
|
2020-11-20 10:47:16 +00:00
|
|
|
cli.Connect()
|
2020-11-24 11:54:23 +00:00
|
|
|
log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser", nil))
|
|
|
|
log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/yanngu?lang=en&deviceType=browser", "213"))
|
|
|
|
// 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-20 10:47:16 +00:00
|
|
|
http.ListenAndServe(":42311", nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|