Empty multiple selection is not actually supported by any backend
This commit is contained in:
parent
4cbb49f0f6
commit
432e7c9bd3
6 changed files with 50 additions and 71 deletions
|
|
@ -4,8 +4,6 @@ from .probe import BaseProbe
|
|||
|
||||
|
||||
class WindowProbe(BaseProbe):
|
||||
supports_file_dialogs = False
|
||||
|
||||
def __init__(self, app, window):
|
||||
super().__init__(app)
|
||||
|
||||
|
|
@ -41,3 +39,12 @@ class WindowProbe(BaseProbe):
|
|||
|
||||
async def close_stack_trace_dialog(self, dialog, result):
|
||||
pytest.skip("Stack Trace dialog not implemented on Android")
|
||||
|
||||
async def close_save_file_dialog(self, dialog, result):
|
||||
pytest.skip("Save File dialog not implemented on Android")
|
||||
|
||||
async def close_open_file_dialog(self, dialog, result, multiple_select):
|
||||
pytest.skip("Open File dialog not implemented on Android")
|
||||
|
||||
async def close_select_folder_dialog(self, dialog, result, multiple_select):
|
||||
pytest.skip("Select Folder dialog not implemented on Android")
|
||||
|
|
|
|||
|
|
@ -19,10 +19,8 @@ from .probe import BaseProbe
|
|||
|
||||
class WindowProbe(BaseProbe):
|
||||
supports_closable = True
|
||||
supports_file_dialogs = True
|
||||
supports_minimizable = True
|
||||
supports_move_while_hidden = True
|
||||
supports_multiple_select_empty = True
|
||||
supports_multiple_select_folder = True
|
||||
supports_unminimize = True
|
||||
|
||||
|
|
@ -163,18 +161,17 @@ class WindowProbe(BaseProbe):
|
|||
|
||||
if result is not None:
|
||||
if multiple_select:
|
||||
if result:
|
||||
# Since we are mocking selected_path(), it's never actually invoked
|
||||
# under test conditions. Call it just to confirm that it returns the
|
||||
# type we think it does.
|
||||
assert isinstance(dialog.selected_paths(), ObjCListInstance)
|
||||
# Since we are mocking selected_path(), it's never actually invoked
|
||||
# under test conditions. Call it just to confirm that it returns the
|
||||
# type we think it does.
|
||||
assert isinstance(dialog.selected_paths(), ObjCListInstance)
|
||||
|
||||
dialog.selected_paths = Mock(
|
||||
return_value=[
|
||||
NSURL.fileURLWithPath(str(path), isDirectory=False)
|
||||
for path in result
|
||||
]
|
||||
)
|
||||
dialog.selected_paths = Mock(
|
||||
return_value=[
|
||||
NSURL.fileURLWithPath(str(path), isDirectory=False)
|
||||
for path in result
|
||||
]
|
||||
)
|
||||
else:
|
||||
dialog.selected_path = Mock(
|
||||
return_value=NSURL.fileURLWithPath(
|
||||
|
|
@ -183,17 +180,10 @@ class WindowProbe(BaseProbe):
|
|||
)
|
||||
)
|
||||
|
||||
# If there's nothing selected, you can't press OK.
|
||||
if result:
|
||||
self.native.endSheet(
|
||||
self.native.attachedSheet,
|
||||
returnCode=NSModalResponseOK,
|
||||
)
|
||||
else:
|
||||
self.native.endSheet(
|
||||
self.native.attachedSheet,
|
||||
returnCode=NSModalResponseCancel,
|
||||
)
|
||||
self.native.endSheet(
|
||||
self.native.attachedSheet,
|
||||
returnCode=NSModalResponseOK,
|
||||
)
|
||||
else:
|
||||
self.native.endSheet(
|
||||
self.native.attachedSheet,
|
||||
|
|
@ -210,18 +200,17 @@ class WindowProbe(BaseProbe):
|
|||
|
||||
if result is not None:
|
||||
if multiple_select:
|
||||
if result:
|
||||
# Since we are mocking selected_path(), it's never actually invoked
|
||||
# under test conditions. Call it just to confirm that it returns the
|
||||
# type we think it does.
|
||||
assert isinstance(dialog.selected_paths(), ObjCListInstance)
|
||||
# Since we are mocking selected_path(), it's never actually invoked
|
||||
# under test conditions. Call it just to confirm that it returns the
|
||||
# type we think it does.
|
||||
assert isinstance(dialog.selected_paths(), ObjCListInstance)
|
||||
|
||||
dialog.selected_paths = Mock(
|
||||
return_value=[
|
||||
NSURL.fileURLWithPath(str(path), isDirectory=True)
|
||||
for path in result
|
||||
]
|
||||
)
|
||||
dialog.selected_paths = Mock(
|
||||
return_value=[
|
||||
NSURL.fileURLWithPath(str(path), isDirectory=True)
|
||||
for path in result
|
||||
]
|
||||
)
|
||||
else:
|
||||
dialog.selected_path = Mock(
|
||||
return_value=NSURL.fileURLWithPath(
|
||||
|
|
@ -230,17 +219,10 @@ class WindowProbe(BaseProbe):
|
|||
)
|
||||
)
|
||||
|
||||
# If there's nothing selected, you can't press OK.
|
||||
if result:
|
||||
self.native.endSheet(
|
||||
self.native.attachedSheet,
|
||||
returnCode=NSModalResponseOK,
|
||||
)
|
||||
else:
|
||||
self.native.endSheet(
|
||||
self.native.attachedSheet,
|
||||
returnCode=NSModalResponseCancel,
|
||||
)
|
||||
self.native.endSheet(
|
||||
self.native.attachedSheet,
|
||||
returnCode=NSModalResponseOK,
|
||||
)
|
||||
else:
|
||||
self.native.endSheet(
|
||||
self.native.attachedSheet,
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ class WindowProbe(BaseProbe):
|
|||
# GTK defers a lot of window behavior to the window manager, which means some features
|
||||
# either don't exist, or we can't guarantee they behave the way Toga would like.
|
||||
supports_closable = True
|
||||
supports_file_dialogs = True
|
||||
supports_minimizable = False
|
||||
supports_multiple_select_empty = True
|
||||
supports_multiple_select_folder = True
|
||||
supports_move_while_hidden = False
|
||||
supports_unminimize = False
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ from .probe import BaseProbe
|
|||
|
||||
|
||||
class WindowProbe(BaseProbe):
|
||||
supports_file_dialogs = False
|
||||
|
||||
def __init__(self, app, window):
|
||||
super().__init__()
|
||||
self.app = app
|
||||
|
|
@ -62,3 +60,12 @@ class WindowProbe(BaseProbe):
|
|||
|
||||
async def close_stack_trace_dialog(self, dialog, result):
|
||||
pytest.skip("Stack Trace dialog not implemented on iOS")
|
||||
|
||||
async def close_save_file_dialog(self, dialog, result):
|
||||
pytest.skip("Save File dialog not implemented on iOS")
|
||||
|
||||
async def close_open_file_dialog(self, dialog, result, multiple_select):
|
||||
pytest.skip("Open File dialog not implemented on iOS")
|
||||
|
||||
async def close_select_folder_dialog(self, dialog, result, multiple_select):
|
||||
pytest.skip("Select Folder dialog not implemented on iOS")
|
||||
|
|
|
|||
|
|
@ -548,9 +548,6 @@ async def test_save_file_dialog(
|
|||
result,
|
||||
):
|
||||
"""A file open dialog can be displayed and acknowledged."""
|
||||
if not main_window_probe.supports_file_dialogs:
|
||||
pytest.xfail("This backend doesn't support file dialogs")
|
||||
|
||||
on_result_handler = Mock()
|
||||
dialog_result = main_window.save_file_dialog(
|
||||
"Save file",
|
||||
|
|
@ -589,8 +586,8 @@ async def test_save_file_dialog(
|
|||
True,
|
||||
[TESTS_DIR / "conftest.py", TESTS_DIR / "data.py"],
|
||||
),
|
||||
# Successful multiple selection of no items
|
||||
(TESTS_DIR, None, True, []),
|
||||
# Successful multiple selection of one item
|
||||
(TESTS_DIR, None, True, [TESTS_DIR / "data.py"]),
|
||||
# Cancelled multiple selection
|
||||
(TESTS_DIR, None, True, None),
|
||||
# Successful multiple selection with no initial directory
|
||||
|
|
@ -613,11 +610,6 @@ async def test_open_file_dialog(
|
|||
result,
|
||||
):
|
||||
"""A file open dialog can be displayed and acknowledged."""
|
||||
if not main_window_probe.supports_file_dialogs:
|
||||
pytest.xfail("This backend doesn't support file dialogs")
|
||||
if result == [] and not main_window_probe.supports_multiple_select_empty:
|
||||
pytest.xfail("This backend doesn't support empty multiple selections")
|
||||
|
||||
on_result_handler = Mock()
|
||||
dialog_result = main_window.open_file_dialog(
|
||||
"Open file",
|
||||
|
|
@ -644,8 +636,8 @@ async def test_open_file_dialog(
|
|||
(None, False, TESTS_DIR / "widgets"),
|
||||
# Successful multiple selection
|
||||
(TESTS_DIR, True, [TESTS_DIR, TESTS_DIR / "widgets"]),
|
||||
# Successful multiple selection with no items
|
||||
(TESTS_DIR, True, []),
|
||||
# Successful multiple selection with one item
|
||||
(TESTS_DIR, True, [TESTS_DIR / "widgets"]),
|
||||
# Cancelled multiple selection
|
||||
(TESTS_DIR, True, None),
|
||||
],
|
||||
|
|
@ -658,11 +650,6 @@ async def test_select_folder_dialog(
|
|||
result,
|
||||
):
|
||||
"""A folder selection dialog can be displayed and acknowledged."""
|
||||
if not main_window_probe.supports_file_dialogs:
|
||||
pytest.xfail("This backend doesn't support file dialogs")
|
||||
if result == [] and not main_window_probe.supports_multiple_select_empty:
|
||||
pytest.xfail("This backend doesn't support empty multiple selections")
|
||||
|
||||
on_result_handler = Mock()
|
||||
dialog_result = main_window.select_folder_dialog(
|
||||
"Select folder",
|
||||
|
|
|
|||
|
|
@ -11,10 +11,8 @@ class WindowProbe(BaseProbe):
|
|||
# (https://stackoverflow.com/a/7301828), which Python.NET doesn't support
|
||||
# (https://github.com/pythonnet/pythonnet/issues/2192).
|
||||
supports_closable = False
|
||||
supports_file_dialogs = True
|
||||
supports_minimizable = True
|
||||
supports_move_while_hidden = True
|
||||
supports_multiple_select_empty = False
|
||||
supports_multiple_select_folder = False
|
||||
supports_unminimize = True
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue