Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
De-duplicate list lookup code and test
Moved code round a little so settings were in a sensible place
- Loading branch information
1 parent
c741019
commit 8e18a13
Showing
5 changed files
with
83 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package ui | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"fyne.io/fynedesk" | ||
) | ||
|
||
func TestDeskSettings_IsModuleEnabled(t *testing.T) { | ||
s := &testSettings{moduleNames: []string{"Yes", "maybe"}} | ||
|
||
assert.True(t, isModuleEnabled("Yes", s)) | ||
assert.True(t, isModuleEnabled("maybe", s)) | ||
assert.False(t, isModuleEnabled("Maybe", s)) | ||
assert.False(t, isModuleEnabled("No", s)) | ||
} | ||
|
||
type testSettings struct { | ||
background string | ||
iconTheme string | ||
launcherIcons []string | ||
launcherIconSize int | ||
launcherZoomScale float64 | ||
launcherDisableZoom bool | ||
launcherDisableTaskbar bool | ||
|
||
moduleNames []string | ||
} | ||
|
||
func (ts *testSettings) IconTheme() string { | ||
return ts.iconTheme | ||
} | ||
|
||
func (ts *testSettings) Background() string { | ||
return ts.background | ||
} | ||
|
||
func (ts *testSettings) LauncherIcons() []string { | ||
return ts.launcherIcons | ||
} | ||
|
||
func (ts *testSettings) LauncherIconSize() int { | ||
if ts.launcherIconSize == 0 { | ||
return 32 | ||
} | ||
return ts.launcherIconSize | ||
} | ||
|
||
func (ts *testSettings) LauncherDisableTaskbar() bool { | ||
return ts.launcherDisableTaskbar | ||
} | ||
|
||
func (ts *testSettings) LauncherDisableZoom() bool { | ||
return ts.launcherDisableZoom | ||
} | ||
|
||
func (ts *testSettings) LauncherZoomScale() float64 { | ||
if ts.launcherZoomScale == 0 { | ||
return 1.0 | ||
} | ||
return ts.launcherZoomScale | ||
} | ||
|
||
func (ts *testSettings) ModuleNames() []string { | ||
return ts.moduleNames | ||
} | ||
|
||
func (*testSettings) AddChangeListener(listener chan fynedesk.DeskSettings) { | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters