Harden display collection returns
This commit is contained in:
parent
337590573b
commit
3c06621999
2 changed files with 24 additions and 3 deletions
|
|
@ -1120,9 +1120,12 @@ func (s *Service) GetWindowInfo(name string) (*window.WindowInfo, error) {
|
|||
func (s *Service) ListWindowInfos() []window.WindowInfo {
|
||||
r := s.Core().QUERY(window.QueryWindowList{})
|
||||
if !r.OK {
|
||||
return nil
|
||||
return []window.WindowInfo{}
|
||||
}
|
||||
list, _ := r.Value.([]window.WindowInfo)
|
||||
if list == nil {
|
||||
return []window.WindowInfo{}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
|
|
@ -1340,7 +1343,7 @@ func (s *Service) ResetWindowState() error {
|
|||
func (s *Service) GetSavedWindowStates() map[string]window.WindowState {
|
||||
ws := s.windowService()
|
||||
if ws == nil {
|
||||
return nil
|
||||
return map[string]window.WindowState{}
|
||||
}
|
||||
result := make(map[string]window.WindowState)
|
||||
for _, name := range ws.Manager().State().ListStates() {
|
||||
|
|
@ -1424,9 +1427,12 @@ func (s *Service) RestoreLayout(name string) error {
|
|||
func (s *Service) ListLayouts() []window.LayoutInfo {
|
||||
r := s.Core().QUERY(window.QueryLayoutList{})
|
||||
if !r.OK {
|
||||
return nil
|
||||
return []window.LayoutInfo{}
|
||||
}
|
||||
layouts, _ := r.Value.([]window.LayoutInfo)
|
||||
if layouts == nil {
|
||||
return []window.LayoutInfo{}
|
||||
}
|
||||
return layouts
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -760,6 +760,21 @@ func TestGetSavedWindowStates_Good(t *testing.T) {
|
|||
assert.NotNil(t, states)
|
||||
}
|
||||
|
||||
func TestDisplay_PublicCollections_AreNilSafe(t *testing.T) {
|
||||
svc, _ := newTestDisplayService(t)
|
||||
|
||||
infos := svc.ListWindowInfos()
|
||||
layouts := svc.ListLayouts()
|
||||
states := svc.GetSavedWindowStates()
|
||||
|
||||
require.NotNil(t, infos)
|
||||
require.NotNil(t, layouts)
|
||||
require.NotNil(t, states)
|
||||
assert.Empty(t, infos)
|
||||
assert.Empty(t, layouts)
|
||||
assert.Empty(t, states)
|
||||
}
|
||||
|
||||
func TestHandleIPCEvents_WindowOpened_Good(t *testing.T) {
|
||||
c := newTestConclave(t)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue