diff --git a/resource.go b/resource.go index b8d9deb619..d221316277 100644 --- a/resource.go +++ b/resource.go @@ -7,7 +7,6 @@ package fyne type Resource interface { Name() string Content() []byte - CachePath() string } // StaticResource is a bundled resource compiled into the application. @@ -30,18 +29,6 @@ func (r *StaticResource) Content() []byte { return r.StaticContent } -// CachePath will return the cached location of a resource. -// If the resource has not previously been written to a cache this operation -// will block until the data is available at the returned location. -func (r *StaticResource) CachePath() string { - path := cachePath(r.StaticName) - if !pathExists(path) { - toFile(r) - } - - return path -} - // NewStaticResource returns a new static resource object with the specified // name and content. Creating a new static resource in memory results in // sharable binary data that may be serialised to the location returned by diff --git a/resource_test.go b/resource_test.go index 7cdc743d72..3a38c16d04 100644 --- a/resource_test.go +++ b/resource_test.go @@ -1,7 +1,6 @@ package fyne import ( - "os" "testing" "github.com/stretchr/testify/assert" @@ -15,15 +14,3 @@ func TestNewResource(t *testing.T) { assert.Equal(t, name, res.Name()) assert.Equal(t, content, res.Content()) } - -func TestResourceFile(t *testing.T) { - content := []byte{1, 2, 3, 4} - - res := NewStaticResource("file.dat", content) - path := res.CachePath() - - assert.True(t, path != "") - assert.True(t, pathExists(path)) - - os.Remove(path) -} diff --git a/serialise.go b/serialise.go index bb67e40e00..b0d2d0a250 100644 --- a/serialise.go +++ b/serialise.go @@ -3,23 +3,8 @@ package fyne import ( "bytes" "fmt" - "io/ioutil" ) -func fromFile(name string) Resource { - data, err := ioutil.ReadFile(cachePath(name)) - - if err != nil { - return nil - } - - return NewStaticResource(name, data) -} - -func toFile(res *StaticResource) { - ioutil.WriteFile(cachePath(res.StaticName), res.StaticContent, 0644) -} - // GoString converts a Resource object to Go code. // This is useful if serialising to a Go file for compilation into a binary. func (r *StaticResource) GoString() string { diff --git a/serialise_test.go b/serialise_test.go index e6c3bc0f5f..3b4a4a9c97 100644 --- a/serialise_test.go +++ b/serialise_test.go @@ -1,7 +1,6 @@ package fyne import ( - "os" "testing" "github.com/stretchr/testify/assert" @@ -14,25 +13,6 @@ var imgGo = `&fyne.StaticResource{ StaticContent: []byte{ 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 1, 0, 0, 0, 1, 8, 2, 0, 0, 0, 144, 119, 83, 222, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 11, 19, 0, 0, 11, 19, 1, 0, 154, 156, 24, 0, 0, 0, 7, 116, 73, 77, 69, 7, 226, 6, 5, 15, 49, 19, 102, 121, 20, 234, 0, 0, 0, 29, 105, 84, 88, 116, 67, 111, 109, 109, 101, 110, 116, 0, 0, 0, 0, 0, 67, 114, 101, 97, 116, 101, 100, 32, 119, 105, 116, 104, 32, 71, 73, 77, 80, 100, 46, 101, 7, 0, 0, 0, 12, 73, 68, 65, 84, 8, 215, 99, 248, 207, 192, 0, 0, 3, 1, 1, 0, 24, 221, 141, 176, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130}}` -func TestToFromFile(t *testing.T) { - path := cachePath(imgName) - - res := NewStaticResource(imgName, imgBytes) - toFile(res) - assert.True(t, path != "") - if !pathExists(path) { - t.Errorf("%s was not written", imgName) - return - } - - res2 := fromFile(imgName) - assert.True(t, res2 != nil) - assert.Equal(t, imgName, res2.Name()) - assert.Equal(t, imgBytes, res2.Content()) - - os.Remove(path) -} - func TestToGo(t *testing.T) { res := NewStaticResource(imgName, imgBytes) diff --git a/theme/icons.go b/theme/icons.go index c34fd6e484..05dcfa8fc7 100644 --- a/theme/icons.go +++ b/theme/icons.go @@ -32,15 +32,6 @@ func (res *ThemedResource) Content() []byte { return res.dark.Content() } -// CachePath returns the cachepath of the correct resource for the current theme setting -func (res *ThemedResource) CachePath() string { - if isThemeLight() { - return res.light.CachePath() - } - - return res.dark.CachePath() -} - // NewThemedResource creates a resource that adapts to the current theme setting. // It is currently a simple pairing of a dark and light variant of the same resource. func NewThemedResource(dark, light fyne.Resource) *ThemedResource { diff --git a/theme/icons_test.go b/theme/icons_test.go index 3556b567d1..2e902ffdb3 100644 --- a/theme/icons_test.go +++ b/theme/icons_test.go @@ -25,12 +25,3 @@ func TestIconThemeChangeContent(t *testing.T) { fyne.CurrentApp().Settings().SetTheme(LightTheme()) assert.NotEqual(t, content, cancel.Content()) } - -func TestIconThemeChangePath(t *testing.T) { - fyne.CurrentApp().Settings().SetTheme(DarkTheme()) - checked := CheckButtonIcon() - path := checked.CachePath() - - fyne.CurrentApp().Settings().SetTheme(LightTheme()) - assert.NotEqual(t, path, checked.CachePath()) -}