Chromium Code Reviews| Index: ppapi/shared_impl/unittest_utils.cc |
| diff --git a/ppapi/shared_impl/unittest_utils.cc b/ppapi/shared_impl/unittest_utils.cc |
| index f5d064b4db669e0ad939a55ebfca05cb2ce99ab0..f613882dde54291c30c4b2ed2e8249a88961aecf 100644 |
| --- a/ppapi/shared_impl/unittest_utils.cc |
| +++ b/ppapi/shared_impl/unittest_utils.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/logging.h" |
| #include "ppapi/shared_impl/array_var.h" |
| #include "ppapi/shared_impl/dictionary_var.h" |
| +#include "ppapi/shared_impl/resource_var.h" |
| #include "ppapi/shared_impl/var.h" |
| #include "ppapi/shared_impl/var_tracker.h" |
| @@ -151,6 +152,39 @@ bool Equals(const PP_Var& expected, |
| } |
| return true; |
| } |
| + case PP_VARTYPE_RESOURCE: { |
| + ResourceVar* expected_var = ResourceVar::FromPPVar(expected); |
| + ResourceVar* actual_var = ResourceVar::FromPPVar(actual); |
| + DCHECK(expected_var && actual_var); |
| + if (expected_var->pp_resource() != actual_var->pp_resource()) { |
| + LOG(ERROR) << "expected: " << expected_var->pp_resource() << " actual: " |
| + << actual_var->pp_resource(); |
| + return false; |
| + } |
| + IPC::Message actual_message(actual_var->creation_message()); |
| + const IPC::Message& expected_message = expected_var->creation_message(); |
| + if (expected_message.size() != actual_message.size()) { |
| + LOG(ERROR) << "expected creation message size: " |
| + << expected_message.size() << " actual: " |
| + << actual_message.size(); |
| + return false; |
| + } |
| + |
| + // Set the upper 24 bits of actual creation_message flags to the same as |
| + // expected. This is an unpredictable reference number that changes |
| + // between serialization/deserialization, and we do not want it to cause |
| + // the comparison to fail. |
| + actual_message.SetHeaderValues(actual_message.routing_id(), |
| + actual_message.type(), |
| + (expected_message.flags() & 0xffffff00) | |
| + (actual_message.flags() & 0xff)); |
| + if (memcmp(expected_message.data(), actual_message.data(), |
| + expected_message.size()) != 0) { |
|
dmichael (off chromium)
2013/09/11 18:30:05
Why not just memcmp the data that is expected to b
Matt Giuca
2013/09/12 07:08:24
That would assume implementation details about the
|
| + LOG(ERROR) << "expected creation message does not match actual."; |
| + return false; |
| + } |
| + return true; |
| + } |
| } |
| NOTREACHED(); |
| return false; |