Skip to content

Commit

Permalink
Correct testbed icon tests, and add explicit platform icon test.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Dec 6, 2023
1 parent 2706683 commit 27b1f7d
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 7 deletions.
12 changes: 11 additions & 1 deletion android/tests_backend/icons.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from pathlib import Path

import pytest
from android.graphics import Bitmap

import toga_android

from .probe import BaseProbe


Expand All @@ -26,4 +30,10 @@ def assert_icon_content(self, path):
pytest.fail("Unknown icon resource")

def assert_default_icon_content(self):
assert self.icon._impl.path == self.app.paths.toga / "resources/toga.png"
assert (
self.icon._impl.path
== Path(toga_android.__file__).parent / "resources/toga.png"
)

def assert_platform_icon_content(self):
assert self.icon._impl.path == self.app.paths.app / "resources/logo-android.png"
11 changes: 10 additions & 1 deletion cocoa/tests_backend/icons.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from pathlib import Path

import pytest

import toga_cocoa
from toga_cocoa.libs import NSImage

from .probe import BaseProbe
Expand Down Expand Up @@ -28,4 +31,10 @@ def assert_icon_content(self, path):
pytest.fail("Unknown icon resource")

def assert_default_icon_content(self):
assert self.icon._impl.path == self.app.paths.toga / "resources/toga.icns"
assert (
self.icon._impl.path
== Path(toga_cocoa.__file__).parent / "resources/toga.icns"
)

def assert_platform_icon_content(self):
assert self.icon._impl.path == self.app.paths.app / "resources/logo-macOS.icns"
16 changes: 13 additions & 3 deletions gtk/tests_backend/icons.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from pathlib import Path

import pytest

import toga_gtk
from toga_gtk.libs import GdkPixbuf

from .probe import BaseProbe
Expand Down Expand Up @@ -34,7 +37,14 @@ def assert_icon_content(self, path):

def assert_default_icon_content(self):
assert self.icon._impl.paths == {
16: self.app.paths.toga / "resources/toga.png",
32: self.app.paths.toga / "resources/toga.png",
72: self.app.paths.toga / "resources/toga.png",
16: Path(toga_gtk.__file__).parent / "resources/toga.png",
32: Path(toga_gtk.__file__).parent / "resources/toga.png",
72: Path(toga_gtk.__file__).parent / "resources/toga.png",
}

def assert_platform_icon_content(self):
assert self.icon._impl.paths == {
16: self.app.paths.app / "resources/logo-linux-16.png",
32: self.app.paths.app / "resources/logo-linux-32.png",
72: self.app.paths.app / "resources/logo-linux-72.png",
}
11 changes: 10 additions & 1 deletion iOS/tests_backend/icons.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from pathlib import Path

import pytest

import toga_iOS
from toga_iOS.libs import UIImage

from .probe import BaseProbe
Expand Down Expand Up @@ -28,4 +31,10 @@ def assert_icon_content(self, path):
pytest.fail("Unknown icon resource")

def assert_default_icon_content(self):
assert self.icon._impl.path == self.app.paths.toga / "resources/toga.icns"
assert (
self.icon._impl.path
== Path(toga_iOS.__file__).parent / "resources/toga.icns"
)

def assert_platform_icon_content(self):
assert self.icon._impl.path == self.app.paths.app / "resources/logo-iOS.icns"
Binary file added testbed/src/testbed/resources/logo-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/logo-iOS.icns
Binary file not shown.
Binary file added testbed/src/testbed/resources/logo-linux-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/logo-linux-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/logo-linux-72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testbed/src/testbed/resources/logo-macOS.icns
Binary file not shown.
Binary file added testbed/src/testbed/resources/logo-windows.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions testbed/tests/test_icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ async def test_system_icon(app):
probe.assert_default_icon_content()


async def test_platform_icon(app):
"A platform-specific icon can be loaded"
probe = icon_probe(app, toga.Icon("resources/logo"))
probe.assert_platform_icon_content()


async def test_bad_icon_file(app):
"If a file isn't a loadable icon, an error is raised"
with pytest.raises(
Expand Down
14 changes: 13 additions & 1 deletion winforms/tests_backend/icons.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from pathlib import Path

import pytest
from System.Drawing import Icon as WinIcon

import toga_winforms

from .probe import BaseProbe


Expand All @@ -26,4 +30,12 @@ def assert_icon_content(self, path):
pytest.fail("Unknown icon resource")

def assert_default_icon_content(self):
assert self.icon._impl.path == self.app.paths.toga / "resources/toga.ico"
assert (
self.icon._impl.path
== Path(toga_winforms.__file__).parent / "resources/toga.ico"
)

def assert_platform_icon_content(self):
assert (
self.icon._impl.path == self.app.paths.app / "resources/logo-winforms.ico"
)

0 comments on commit 27b1f7d

Please sign in to comment.