Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
goanpeca committed Oct 16, 2024
1 parent edbbe78 commit 7271a82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
5 changes: 4 additions & 1 deletion napari_plugin_manager/_tests/test_qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,17 @@ def test_direct_entry_installs(qtbot, tmp_virtualenv, plugin_dialog, request):
@pytest.mark.skipif(
sys.platform.startswith('linux'), reason="Test fails on linux randomly"
)
def test_shortcut_close(plugin_dialog, qtbot, request):
def test_shortcut_close(plugin_dialog, qtbot):
qtbot.keyClicks(
plugin_dialog, 'W', modifier=Qt.KeyboardModifier.ControlModifier
)
qtbot.wait(500)
assert not plugin_dialog.isVisible()


@pytest.mark.skipif(
sys.platform.startswith('linux'), reason="Test fails on linux randomly"
)
def test_shortcut_quit(plugin_dialog, qtbot):
qtbot.keyClicks(
plugin_dialog, 'Q', modifier=Qt.KeyboardModifier.ControlModifier
Expand Down
14 changes: 0 additions & 14 deletions napari_plugin_manager/qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,13 +889,8 @@ def __init__(self, parent=None, prefix=None) -> None:
self._plugin_data = [] # Store all plugin data
self._filter_texts = []
self._filter_idxs_cache = set()
self._filter_timer = QTimer(self)
self.worker = None

# timer to avoid triggering a filter for every keystroke
self._filter_timer.setInterval(200) # ms
self._filter_timer.timeout.connect(self.search)
self._filter_timer.setSingleShot(True)
self._plugin_data_map = {}
self._add_items_timer = QTimer(self)

Expand Down Expand Up @@ -1132,7 +1127,6 @@ def _fetch_available_plugins(self, clear_cache: bool = False):
self.worker.started.connect(self.working_indicator.show)
self.worker.finished.connect(self.working_indicator.hide)
self.worker.finished.connect(self.finished)
# self.worker.finished.connect(self._add_items_timer.start)
self.worker.start()

pm2 = npe2.PluginManager.instance()
Expand All @@ -1157,7 +1151,6 @@ def _setup_ui(self):
self.packages_search.setPlaceholderText(trans._("search..."))
self.packages_search.setMaximumWidth(350)
self.packages_search.setClearButtonEnabled(True)
# self.packages_search.textChanged.connect(self._filter_timer.start)
self.packages_search.textChanged.connect(self.search)

self.refresh_button = QPushButton(trans._('Refresh'), self)
Expand All @@ -1175,7 +1168,6 @@ def _setup_ui(self):
horizontal_mid_layout.addStretch()
horizontal_mid_layout.addWidget(self.refresh_button)
mid_layout.addLayout(horizontal_mid_layout)
# mid_layout.addWidget(self.packages_search)
mid_layout.addWidget(self.installed_label)
lay.addLayout(mid_layout)

Expand Down Expand Up @@ -1281,7 +1273,6 @@ def _setup_ui(self):
self.v_splitter.setStretchFactor(1, 2)
self.h_splitter.setStretchFactor(0, 2)

# self.packages_filter.setFocus()
self.packages_search.setFocus()
self._update_direct_entry_text()

Expand Down Expand Up @@ -1430,8 +1421,6 @@ def _add_items(self):
break

self._update_plugin_count()
# if not self._filter_timer.isActive():
# self.search(None, skip=True)

def _handle_yield(self, data: Tuple[npe2.PackageMetadata, bool, Dict]):
"""Output from a worker process.
Expand All @@ -1442,7 +1431,6 @@ def _handle_yield(self, data: Tuple[npe2.PackageMetadata, bool, Dict]):
method to prevent the UI from freezing by adding all items at once.
"""
self._plugin_data.append(data)
# self._plugin_queue.append(data)
self._filter_texts = [
f"{i[0].name} {i[-1].get('display_name', '')} {i[0].summary}".lower()
for i in self._plugin_data
Expand All @@ -1455,7 +1443,6 @@ def _handle_yield(self, data: Tuple[npe2.PackageMetadata, bool, Dict]):
def _search_in_available(self, text):
idxs = []
for idx, item in enumerate(self._filter_texts):
# if text.lower().strip() in item and idx not in self._filter_idxs_cache:
if text.lower().strip() in item:
idxs.append(idx)
self._filter_idxs_cache.add(idx)
Expand All @@ -1470,7 +1457,6 @@ def _refresh_and_clear_cache(self):
# region - Qt overrides
# ------------------------------------------------------------------------
def closeEvent(self, event):
print('CLOSE EVENT CALLED')
if self._parent is not None:
plugin_dialog = getattr(self._parent, '_plugin_dialog', self)
if self != plugin_dialog:
Expand Down

0 comments on commit 7271a82

Please sign in to comment.