-
Notifications
You must be signed in to change notification settings - Fork 6k
[Linux] add MockSignalHandler for testing GObject signals #32650
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
b94ef8b to
8fd30ea
Compare
This is a simple helper class that allows settings GMock expectations on GObject signals: ```c GObject* foo_object = ...; flutter::testing::MockSignalHandler foo_changed(foo_object, "changed"); EXPECT_SIGNAL(foo_changed).Times(1); foo_set_something(foo_object, ...); ```
8fd30ea to
9cd5982
Compare
robert-ancell
left a comment
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.
LGTM
g_object_add_weak_pointer() does not assign the initial value
|
Here's an example of matching and capturing signal arguments: AtkObject* child2_object = nullptr;
flutter::testing::MockSignalHandler2<gint, AtkObject*> child2_added(
root_object, "children-changed::add");
EXPECT_SIGNAL2(child2_added, ::testing::Eq(1), ::testing::A<AtkObject*>())
.WillOnce(::testing::SaveArg<1>(&child2_object)); |
This is a preparation step split off from #32618 that will eventually fix light
vs. dark theme detection on Linux (flutter/flutter#101438).
MockSignalHandleris a helper class that allows settings GMock expectationson
GObjectsignals:Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.