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 f613882dde54291c30c4b2ed2e8249a88961aecf..84821093304b66adeaa46a5a6c04af1d33ee3311 100644 |
| --- a/ppapi/shared_impl/unittest_utils.cc |
| +++ b/ppapi/shared_impl/unittest_utils.cc |
| @@ -161,27 +161,39 @@ bool Equals(const PP_Var& expected, |
| << 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(); |
| + HostResourceVar* expected_host_var = expected_var->AsHostResourceVar(); |
| + HostResourceVar* actual_host_var = expected_var->AsHostResourceVar(); |
| + if (expected_host_var && !actual_host_var) { |
| + LOG(ERROR) << "expected var is host, actual is not host"; |
| + return false; |
| + } else if (!expected_host_var && actual_host_var) { |
| + LOG(ERROR) << "expected var is not host, actual is host"; |
| return false; |
| } |
| + if (expected_host_var) { |
| + IPC::Message actual_message(actual_host_var->creation_message()); |
| + const IPC::Message& expected_message = |
| + expected_host_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) { |
| - LOG(ERROR) << "expected creation message does not match actual."; |
| - 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) | |
|
dmichael (off chromium)
2013/09/13 17:29:03
I think I mentioned this in another CL... would i
raymes
2013/09/13 17:41:33
+1
Matt Giuca
2013/09/13 21:23:11
See my response there:
https://codereview.chromium
dmichael (off chromium)
2013/09/13 22:54:45
Okay, thanks. Sorry I missed that. Makes sense.
|
| + (actual_message.flags() & 0xff)); |
| + if (memcmp(expected_message.data(), actual_message.data(), |
| + expected_message.size()) != 0) { |
| + LOG(ERROR) << "expected creation message does not match actual."; |
| + return false; |
| + } |
| } |
| return true; |
| } |