| Index: tests/PathTest.cpp
|
| diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
|
| index 313d84a142bc9c84a029c8968df0ef64d693b408..0453bdd9f70cda0f319e3810e8012afd31d45bdd 100644
|
| --- a/tests/PathTest.cpp
|
| +++ b/tests/PathTest.cpp
|
| @@ -3699,6 +3699,64 @@ public:
|
| }
|
| };
|
|
|
| +namespace {
|
| +
|
| +class ChangeListener : public SkPathRef::GenIDChangeListener {
|
| +public:
|
| + ChangeListener(bool *changed) : fChanged(changed) { *fChanged = false; }
|
| + virtual ~ChangeListener() {}
|
| + void onChange() override {
|
| + *fChanged = true;
|
| + }
|
| +private:
|
| + bool* fChanged;
|
| +};
|
| +
|
| +}
|
| +
|
| +static void test_pathref_listeners(skiatest::Reporter* reporter) {
|
| + SkPath p;
|
| +
|
| + bool changed = false;
|
| + p.moveTo(0, 0);
|
| +
|
| + // Check that listener is notified on moveTo().
|
| + p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
|
| + REPORTER_ASSERT(reporter, !changed);
|
| + p.moveTo(10, 0);
|
| + REPORTER_ASSERT(reporter, changed);
|
| +
|
| + // Check that listener is notified on lineTo().
|
| + p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
|
| + REPORTER_ASSERT(reporter, !changed);
|
| + p.lineTo(20, 0);
|
| + REPORTER_ASSERT(reporter, changed);
|
| +
|
| + // Check that listener is notified on reset().
|
| + p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
|
| + REPORTER_ASSERT(reporter, !changed);
|
| + p.reset();
|
| + REPORTER_ASSERT(reporter, changed);
|
| +
|
| + p.moveTo(0, 0);
|
| +
|
| + // Check that listener is notified on rewind().
|
| + p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
|
| + REPORTER_ASSERT(reporter, !changed);
|
| + p.rewind();
|
| + REPORTER_ASSERT(reporter, changed);
|
| +
|
| + // Check that listener is notified when pathref is deleted.
|
| + {
|
| + SkPath q;
|
| + q.moveTo(10, 10);
|
| + q.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
|
| + REPORTER_ASSERT(reporter, !changed);
|
| + }
|
| + // q went out of scope.
|
| + REPORTER_ASSERT(reporter, changed);
|
| +}
|
| +
|
| DEF_TEST(Paths, reporter) {
|
| test_path_crbug364224();
|
|
|
| @@ -3848,4 +3906,5 @@ DEF_TEST(Paths, reporter) {
|
| test_path_crbugskia2820(reporter);
|
| test_skbug_3469(reporter);
|
| test_skbug_3239(reporter);
|
| + test_pathref_listeners(reporter);
|
| }
|
|
|