mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 18:29:53 +08:00
Tidy up. More tests.
This commit is contained in:
parent
dc0d99a8e9
commit
6bfd654ec8
@ -17,7 +17,7 @@ func main() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
// Create window
|
// Create window
|
||||||
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
|
myWindow := app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
|
||||||
Title: "Plain Bundle",
|
Title: "Plain Bundle",
|
||||||
CSS: `body { background-color: rgba(255, 255, 255, 0); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; user-select: none; -ms-user-select: none; -webkit-user-select: none; } .main { color: white; margin: 20%; }`,
|
CSS: `body { background-color: rgba(255, 255, 255, 0); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; user-select: none; -ms-user-select: none; -webkit-user-select: none; } .main { color: white; margin: 20%; }`,
|
||||||
Mac: application.MacWindow{
|
Mac: application.MacWindow{
|
||||||
@ -25,7 +25,6 @@ func main() {
|
|||||||
Backdrop: application.MacBackdropTranslucent,
|
Backdrop: application.MacBackdropTranslucent,
|
||||||
TitleBar: application.MacTitleBarHiddenInsetUnified,
|
TitleBar: application.MacTitleBarHiddenInsetUnified,
|
||||||
},
|
},
|
||||||
|
|
||||||
URL: "/",
|
URL: "/",
|
||||||
Assets: application.AssetOptions{
|
Assets: application.AssetOptions{
|
||||||
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -295,8 +295,6 @@ func (p *Project) parseBoundStructMethods(name string, pkg *ParsedPackage) error
|
|||||||
method := &BoundMethod{
|
method := &BoundMethod{
|
||||||
Name: funcDecl.Name.Name,
|
Name: funcDecl.Name.Name,
|
||||||
DocComment: funcDecl.Doc.Text(),
|
DocComment: funcDecl.Doc.Text(),
|
||||||
Inputs: make([]*Parameter, 0),
|
|
||||||
Outputs: make([]*Parameter, 0),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if funcDecl.Type.Params != nil {
|
if funcDecl.Type.Params != nil {
|
||||||
|
28
v3/internal/parser/parser_external_packages_test.go
Normal file
28
v3/internal/parser/parser_external_packages_test.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package parser
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestExternalPackages(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
dir string
|
||||||
|
wantBoundMethods map[string]map[string][]*BoundMethod
|
||||||
|
wantErr bool
|
||||||
|
}{}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got, err := ParseProject(tt.dir)
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("ParseDirectory() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if diff := cmp.Diff(tt.wantBoundMethods, got.BoundMethods); diff != "" {
|
||||||
|
t.Errorf("ParseDirectory() failed:\n" + diff)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -738,7 +738,6 @@ func TestParseDirectory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Outputs: []*Parameter{},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "PointerMapIntInt",
|
Name: "PointerMapIntInt",
|
||||||
@ -757,7 +756,6 @@ func TestParseDirectory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Outputs: []*Parameter{},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "MapIntPointerInt",
|
Name: "MapIntPointerInt",
|
||||||
@ -776,7 +774,6 @@ func TestParseDirectory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Outputs: []*Parameter{},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "MapIntSliceInt",
|
Name: "MapIntSliceInt",
|
||||||
@ -795,7 +792,6 @@ func TestParseDirectory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Outputs: []*Parameter{},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "MapIntSliceIntInMapIntSliceIntOut",
|
Name: "MapIntSliceIntInMapIntSliceIntOut",
|
||||||
@ -841,25 +837,84 @@ func TestParseDirectory(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Outputs: []*Parameter{},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
//{
|
{
|
||||||
// name: "should find multiple bound services",
|
name: "should find multiple bound services",
|
||||||
// dir: "testdata/struct_literal_multiple",
|
dir: "testdata/struct_literal_multiple",
|
||||||
// //wantModels: []string{"main.GreetService", "main.OtherService"},
|
wantBoundMethods: map[string]map[string][]*BoundMethod{
|
||||||
// wantErr: false,
|
"main": {
|
||||||
//},
|
"GreetService": {
|
||||||
//{
|
{
|
||||||
// name: "should find multiple bound services over multiple files",
|
Name: "Greet",
|
||||||
// dir: "testdata/struct_literal_multiple_files",
|
DocComment: "",
|
||||||
// //wantModels: []string{"main.GreetService", "main.OtherService"},
|
Inputs: []*Parameter{
|
||||||
// wantErr: false,
|
{
|
||||||
//},
|
Name: "name",
|
||||||
|
Type: &ParameterType{
|
||||||
|
Name: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Outputs: []*Parameter{
|
||||||
|
{
|
||||||
|
Name: "",
|
||||||
|
Type: &ParameterType{
|
||||||
|
Name: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"OtherService": {
|
||||||
|
{
|
||||||
|
Name: "Hello",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "should find multiple bound services over multiple files",
|
||||||
|
dir: "testdata/struct_literal_multiple_files",
|
||||||
|
wantBoundMethods: map[string]map[string][]*BoundMethod{
|
||||||
|
"main": {
|
||||||
|
"GreetService": {
|
||||||
|
{
|
||||||
|
Name: "Greet",
|
||||||
|
DocComment: "",
|
||||||
|
Inputs: []*Parameter{
|
||||||
|
{
|
||||||
|
Name: "name",
|
||||||
|
Type: &ParameterType{
|
||||||
|
Name: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Outputs: []*Parameter{
|
||||||
|
{
|
||||||
|
Name: "",
|
||||||
|
Type: &ParameterType{
|
||||||
|
Name: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"OtherService": {
|
||||||
|
{
|
||||||
|
Name: "Hello",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
//{
|
//{
|
||||||
// name: "should find multiple bound services over multiple packages",
|
// name: "should find multiple bound services over multiple packages",
|
||||||
// dir: "testdata/struct_literal_multiple_other",
|
// dir: "testdata/struct_literal_multiple_other",
|
||||||
|
@ -20,6 +20,8 @@ type OtherService struct {
|
|||||||
t int
|
t int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *OtherService) Hello() {}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := application.New(application.Options{
|
app := application.New(application.Options{
|
||||||
Bind: []interface{}{
|
Bind: []interface{}{
|
||||||
|
@ -3,3 +3,5 @@ package main
|
|||||||
type OtherService struct {
|
type OtherService struct {
|
||||||
t int
|
t int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *OtherService) Hello() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user