-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mapping filter in Input section #621
Conversation
Can you encapsulate this functionality better? I would encapsulate the This also makes testing of that component easy, see test_components.py for examples on that. |
Understood, I will give it a try in the next days. |
As far as I remember For buttons use https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Button.html#Gtk.Button.clicked for example. |
You can also use |
I think you can just call the For keyboard events, I did not find a good way to do that. we have For |
6e4b4fd
to
3684604
Compare
When I run the
Other than that, I think the component is now ready and should work with other ListBoxes too. |
aede01f
to
6be2700
Compare
@@ -32,7 +32,7 @@ | |||
from tests.lib.logger import logger | |||
from tests.lib.fixtures import fixtures | |||
from tests.lib.pipes import push_event, push_events, uinput_write_history_pipe | |||
from tests.integration.test_components import FlowBoxTestUtils | |||
from tests.integration.test_components import FlowBoxTestUtils, GtkKeyEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing the GtkKeyEvent class from this file with the import causes the test to fail somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, funny, now it doesn't fix it anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it is a race condition. it fails most of the time, but works sometimes. This could be timing related. Looking at the test, there are some calls to self.throttle
. Something is possibly happening slower than before or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw. I seem to be the only user of the class. Did it serve a purpose before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I found this:
def throttle(self, time_=10):
"""Give GTK some time in ms to process everything."""
# tests suddenly started to freeze my computer up completely and tests started
# to fail. By using this (and by optimizing some redundant calls in the gui) it
# worked again. EDIT: Might have been caused by my broken/bloated ssd. I'll
# keep it in some places, since it did make the tests more reliable after all.
for _ in range(time_ // 2):
gtk_iteration()
time.sleep(0.002)
I wonder if we can use sth. like GLib.timeout_add()
instead. From what I know time.sleep
is discouraged for managing any kind of timing issues. Always try to wait for the desired state to appear, rather than waiting fixed amounts of time. It is just a guess, but time.sleep
may actually prevent other critical code from being executed during the sleep (on the main thread I guess, but I do not know how Python + Gtk works with regards to UI thread vs. background threads) 🤷🏼♂️
I will try to add sth. like this:
self.awaitEqual(
lambda t: self.data_manager.active_preset.get_mapping(
get_combination(combination_1)
).output_symbol,
"a",
timeout=1000, # optional, default maybe at 100
)
self.awaitTrue(
# ...
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think our tests are horribly complicated. I can also see that throttle
might be a bad practice in some places. In others, if I remember correctly, it is just there to give gtk some time to process internal events and stuff and to give it some time to render the gui properly.
test_combination
works when my current PR #578 is merged with yours, so don't worry about it too much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#578 is merged, once you pull the newest changes from beta it should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I resolved the conflicts. Yes the TestGui suite now runs fine 👍🏼.
I separated the ListBox Gtk-specific code from the mapping filter entry in another branch The branch re-adds massaging and includes all changes from this PR. Also, since the Gtk code is very generic, I moved that to another module. @jonasBoss is this more what you had in mind? If yes, I would create another PR for further discussion and close this one. |
I love it 👍. It keeps each class simple and focused on only one task. |
This PR is replaced by a new version of the feature at #628 |
-R
CLI flag to skip thepkexec
dialog without the app failingGtkKeyEvent
to components tests and extened it to emit key events in testsdefault view:

view when filtering:

new usage info: