Closed Bug 1149285 Opened 9 years ago Closed 9 years ago

Add a DeserializedEdge gmock matcher and use it in the gtests for DeserializedNode's ubi::node

Categories

(DevTools :: Memory, defect)

x86
macOS
defect
Not set
normal

Tracking

(firefox45 fixed)

RESOLVED FIXED
Firefox 45
Tracking Status
firefox45 --- fixed

People

(Reporter: fitzgen, Assigned: fitzgen)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

(In reply to Jim Blandy :jimb from bug 1024774 comment #167)
> @@ +63,5 @@
> > +    edge1.referent = referent1->id;
> > +    mocked.addEdge(Move(edge1));
> > +    EXPECT_CALL(mocked,
> > +                getEdgeReferent(Field(&DeserializedEdge::referent,
> > +                                      referent1->id)))
> 
> For the future, it'd be nice to add a DeserializedEdge matcher to
> DevTools.h. Then we could just say exactly what we mean.
Assignee: nobody → nfitzgerald
Has STR: --- → irrelevant
Status: NEW → ASSIGNED
Comment on attachment 8683877 [details] [diff] [review]
Abstract out edge matching with a custom gmock matcher

Review of attachment 8683877 [details] [diff] [review]:
-----------------------------------------------------------------

::: devtools/shared/heapsnapshot/tests/gtest/DeserializedNodeUbiNodes.cpp
@@ +64,5 @@
>                                                                     nullptr,
>                                                                     10));
>      DeserializedEdge edge1(referent1->id);
>      mocked.addEdge(Move(edge1));
> +    EXPECT_CALL(mocked, getEdgeReferent(EdgeTo(referent1->id)))

Whoa EXPECT_CALL is cool.

::: devtools/shared/heapsnapshot/tests/gtest/DevTools.h
@@ +280,5 @@
>  
> +// Matches an edge whose referent is the node with the given id.
> +MATCHER_P(EdgeTo, id, "") {
> +  return Matcher<const DeserializedEdge&>(Field(&DeserializedEdge::referent, id))
> +    .MatchAndExplain(arg, result_listener);

All of the code in here is gorgeous.
Attachment #8683877 - Flags: review?(vporof) → review+
https://hg.mozilla.org/mozilla-central/rev/55759fa6f9dc
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 45
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: