mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 07:40:17 +08:00
Tidy up. More tests.
This commit is contained in:
parent
dc0d99a8e9
commit
6bfd654ec8
@ -17,7 +17,7 @@ func main() {
|
||||
},
|
||||
})
|
||||
// Create window
|
||||
app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
|
||||
myWindow := app.NewWebviewWindowWithOptions(&application.WebviewWindowOptions{
|
||||
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%; }`,
|
||||
Mac: application.MacWindow{
|
||||
@ -25,7 +25,6 @@ func main() {
|
||||
Backdrop: application.MacBackdropTranslucent,
|
||||
TitleBar: application.MacTitleBarHiddenInsetUnified,
|
||||
},
|
||||
|
||||
URL: "/",
|
||||
Assets: application.AssetOptions{
|
||||
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{
|
||||
Name: funcDecl.Name.Name,
|
||||
DocComment: funcDecl.Doc.Text(),
|
||||
Inputs: make([]*Parameter, 0),
|
||||
Outputs: make([]*Parameter, 0),
|
||||
}
|
||||
|
||||
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",
|
||||
@ -757,7 +756,6 @@ func TestParseDirectory(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Outputs: []*Parameter{},
|
||||
},
|
||||
{
|
||||
Name: "MapIntPointerInt",
|
||||
@ -776,7 +774,6 @@ func TestParseDirectory(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Outputs: []*Parameter{},
|
||||
},
|
||||
{
|
||||
Name: "MapIntSliceInt",
|
||||
@ -795,7 +792,6 @@ func TestParseDirectory(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Outputs: []*Parameter{},
|
||||
},
|
||||
{
|
||||
Name: "MapIntSliceIntInMapIntSliceIntOut",
|
||||
@ -841,25 +837,84 @@ func TestParseDirectory(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Outputs: []*Parameter{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
//{
|
||||
// name: "should find multiple bound services",
|
||||
// dir: "testdata/struct_literal_multiple",
|
||||
// //wantModels: []string{"main.GreetService", "main.OtherService"},
|
||||
// wantErr: false,
|
||||
//},
|
||||
//{
|
||||
// name: "should find multiple bound services over multiple files",
|
||||
// dir: "testdata/struct_literal_multiple_files",
|
||||
// //wantModels: []string{"main.GreetService", "main.OtherService"},
|
||||
// wantErr: false,
|
||||
//},
|
||||
{
|
||||
name: "should find multiple bound services",
|
||||
dir: "testdata/struct_literal_multiple",
|
||||
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 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",
|
||||
// dir: "testdata/struct_literal_multiple_other",
|
||||
|
@ -20,6 +20,8 @@ type OtherService struct {
|
||||
t int
|
||||
}
|
||||
|
||||
func (o *OtherService) Hello() {}
|
||||
|
||||
func main() {
|
||||
app := application.New(application.Options{
|
||||
Bind: []interface{}{
|
||||
|
@ -3,3 +3,5 @@ package main
|
||||
type OtherService struct {
|
||||
t int
|
||||
}
|
||||
|
||||
func (o *OtherService) Hello() {}
|
||||
|
Loading…
Reference in New Issue
Block a user