app(xkcdreader): init,get fyne.App from anywhere
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8c72ee9443
commit
5cb040b7a8
@ -17,10 +17,15 @@ import (
|
||||
|
||||
const appGreeting = "welcome to go-xkcdreader"
|
||||
|
||||
var a fyne.App
|
||||
|
||||
// RunApp performs sets up and runs the main application
|
||||
func RunApp() {
|
||||
a := app.New()
|
||||
w := a.NewWindow(cmd.GetAppName())
|
||||
// initialize the fyne application
|
||||
newApp()
|
||||
|
||||
goxkcdreader := getApp()
|
||||
w := goxkcdreader.NewWindow(cmd.GetAppName())
|
||||
|
||||
centered := container.New(
|
||||
layout.NewHBoxLayout(),
|
||||
@ -40,6 +45,15 @@ func RunApp() {
|
||||
w.ShowAndRun()
|
||||
}
|
||||
|
||||
func newApp() {
|
||||
a = app.New()
|
||||
log.Println("Created a new fyne application")
|
||||
}
|
||||
|
||||
func getApp() fyne.App {
|
||||
return a
|
||||
}
|
||||
|
||||
// makeGreeting creates a greeting label
|
||||
func makeGreeting() *widget.Label {
|
||||
w := widget.NewLabel(appGreeting)
|
||||
|
@ -92,3 +92,26 @@ func TestTabs(t *testing.T) {
|
||||
FAIL
|
||||
*/
|
||||
}
|
||||
|
||||
func TestNewApp(t *testing.T) {
|
||||
// init the application
|
||||
newApp()
|
||||
|
||||
// get the application from var a
|
||||
testA := a
|
||||
|
||||
if testA == nil {
|
||||
t.Error("Failed to init application")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetApp(t *testing.T) {
|
||||
// init the application
|
||||
newApp()
|
||||
|
||||
got := getApp()
|
||||
|
||||
if got == nil {
|
||||
t.Error("Failed to get application pointer using getApp()")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user