1 Star 0 Fork 0

zhishy/zserge-webview

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webview_test.go 833 Bytes
一键复制 编辑 原始数据 按行查看 历史
Serge A. Zaitsev 提交于 2020-03-01 22:38 . merge webview-x branch
package webview
import (
"flag"
"log"
"os"
"testing"
)
func Example() {
w := New(true)
defer w.Destroy()
w.SetTitle("Hello")
w.Bind("noop", func() string {
log.Println("hello")
return "hello"
})
w.Bind("add", func(a, b int) int {
return a + b
})
w.Bind("quit", func() {
w.Terminate()
})
w.Navigate(`data:text/html,
<!doctype html>
<html>
<body>hello</body>
<script>
window.onload = function() {
document.body.innerText = ` + "`hello, ${navigator.userAgent}`" + `;
noop().then(function(res) {
console.log('noop res', res);
add(1, 2).then(function(res) {
console.log('add res', res);
quit();
});
});
};
</script>
</html>
)`)
w.Run()
}
func TestMain(m *testing.M) {
flag.Parse()
if testing.Verbose() {
Example()
}
os.Exit(m.Run())
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhishy/zserge-webview.git
git@gitee.com:zhishy/zserge-webview.git
zhishy
zserge-webview
zserge-webview
master

搜索帮助