U: demo update

This commit is contained in:
杨红岩 2024-01-06 23:19:06 +08:00
parent c7cc5ab381
commit c448b3b94f
3 changed files with 2 additions and 92 deletions

View File

@ -1,90 +0,0 @@
package bindata
import (
"regexp"
"strings"
"testing"
)
func TestSafeFunctionName(t *testing.T) {
var knownFuncs = make(map[string]int)
name1 := safeFunctionName("foo/bar", knownFuncs)
name2 := safeFunctionName("foo_bar", knownFuncs)
if name1 == name2 {
t.Errorf("name collision")
}
}
func TestFindFiles(t *testing.T) {
var toc []Asset
var knownFuncs = make(map[string]int)
var visitedPaths = make(map[string]bool)
err := findFiles("testdata/dupname", "testdata/dupname", true, &toc, []*regexp.Regexp{}, knownFuncs, visitedPaths)
if err != nil {
t.Errorf("expected to be no error: %+v", err)
}
if toc[0].Func == toc[1].Func {
t.Errorf("name collision")
}
}
func TestFindFilesWithSymlinks(t *testing.T) {
var tocSrc []Asset
var tocTarget []Asset
var knownFuncs = make(map[string]int)
var visitedPaths = make(map[string]bool)
err := findFiles("testdata/symlinkSrc", "testdata/symlinkSrc", true, &tocSrc, []*regexp.Regexp{}, knownFuncs, visitedPaths)
if err != nil {
t.Errorf("expected to be no error: %+v", err)
}
knownFuncs = make(map[string]int)
visitedPaths = make(map[string]bool)
err = findFiles("testdata/symlinkParent", "testdata/symlinkParent", true, &tocTarget, []*regexp.Regexp{}, knownFuncs, visitedPaths)
if err != nil {
t.Errorf("expected to be no error: %+v", err)
}
if len(tocSrc) != len(tocTarget) {
t.Errorf("Symlink source and target should have the same number of assets. Expected %d got %d", len(tocTarget), len(tocSrc))
} else {
for i := range tocSrc {
targetFunc := strings.TrimPrefix(tocTarget[i].Func, "symlinktarget")
targetFunc = strings.ToLower(targetFunc[:1]) + targetFunc[1:]
if tocSrc[i].Func != targetFunc {
t.Errorf("Symlink source and target produced different function lists. Expected %s to be %s", targetFunc, tocSrc[i].Func)
}
}
}
}
func TestFindFilesWithRecursiveSymlinks(t *testing.T) {
var toc []Asset
var knownFuncs = make(map[string]int)
var visitedPaths = make(map[string]bool)
err := findFiles("testdata/symlinkRecursiveParent", "testdata/symlinkRecursiveParent", true, &toc, []*regexp.Regexp{}, knownFuncs, visitedPaths)
if err != nil {
t.Errorf("expected to be no error: %+v", err)
}
if len(toc) != 1 {
t.Errorf("Only one asset should have been found. Got %d: %v", len(toc), toc)
}
}
func TestFindFilesWithSymlinkedFile(t *testing.T) {
var toc []Asset
var knownFuncs = make(map[string]int)
var visitedPaths = make(map[string]bool)
err := findFiles("testdata/symlinkFile", "testdata/symlinkFile", true, &toc, []*regexp.Regexp{}, knownFuncs, visitedPaths)
if err != nil {
t.Errorf("expected to be no error: %+v", err)
}
if len(toc) != 1 {
t.Errorf("Only one asset should have been found. Got %d: %v", len(toc), toc)
}
}

View File

@ -51,7 +51,7 @@ func main() {
} else if window.IsViewsFramework() { } else if window.IsViewsFramework() {
//VF 窗口是CEF自己创建的这里我们只管Chromium的Close事件即可 //VF 窗口是CEF自己创建的这里我们只管Chromium的Close事件即可
bw := window.AsViewsFrameworkBrowserWindow().BrowserWindow() bw := window.AsViewsFrameworkBrowserWindow().BrowserWindow()
bw.SetOnCloseQuery(func(sender lcl.IObject, cefWindow *cef.ICefWindow, window cef.IBrowserWindow, canClose *bool) bool { bw.SetOnCloseQuery(func(cefWindow *cef.ICefWindow, window cef.IBrowserWindow, canClose *bool) bool {
*canClose = false //取消关闭 , 如果想关闭窗口 true *canClose = false //取消关闭 , 如果想关闭窗口 true
window.Hide() //隐藏窗口 window.Hide() //隐藏窗口
// 5秒后显示窗口 // 5秒后显示窗口

View File

@ -51,7 +51,7 @@ func main() {
} else if window.IsViewsFramework() { } else if window.IsViewsFramework() {
//VF 窗口是CEF自己创建的这里我们只管Chromium的Close事件即可 //VF 窗口是CEF自己创建的这里我们只管Chromium的Close事件即可
bw := window.AsViewsFrameworkBrowserWindow().BrowserWindow() bw := window.AsViewsFrameworkBrowserWindow().BrowserWindow()
bw.SetOnCloseQuery(func(sender lcl.IObject, win *cef.ICefWindow, window cef.IBrowserWindow, canClose *bool) bool { bw.SetOnCloseQuery(func(win *cef.ICefWindow, window cef.IBrowserWindow, canClose *bool) bool {
*canClose = false // 取消关闭 , 如果想关闭窗口 true *canClose = false // 取消关闭 , 如果想关闭窗口 true
window.Minimize() //最小化窗口 window.Minimize() //最小化窗口
// 5秒后显示窗口 // 5秒后显示窗口