Chromium Code Reviews| Index: runtime/vm/snapshot_test.cc |
| diff --git a/runtime/vm/snapshot_test.cc b/runtime/vm/snapshot_test.cc |
| index c00c0f8b5c7e38d6f1538edc8389055575fdde0b..0c4ccaa5544a3926781ca12a14d2591996fbfe78 100644 |
| --- a/runtime/vm/snapshot_test.cc |
| +++ b/runtime/vm/snapshot_test.cc |
| @@ -120,6 +120,9 @@ static void CompareDartCObjects(Dart_CObject* first, Dart_CObject* second) { |
| second->value.as_array.values[i]); |
| } |
| break; |
| + case Dart_CObject_kCapability: |
| + EXPECT_EQ(first->value.as_capability.id, second->value.as_capability.id); |
| + break; |
| default: |
| EXPECT(false); |
| } |
| @@ -402,6 +405,38 @@ static uword allocator(intptr_t size) { |
| } |
| +TEST_CASE(SerializeCapability) { |
| + StackZone zone(Isolate::Current()); |
| + |
| + // Write snapshot with object content. |
| + const Capability& capability = Capability::Handle(Capability::New(12345)); |
| + uint8_t* buffer; |
| + MessageWriter writer(&buffer, &zone_allocator, true); |
| + writer.WriteMessage(capability); |
| + intptr_t buffer_len = writer.BytesWritten(); |
| + |
| + // Read object back from the snapshot. |
| + MessageSnapshotReader reader(buffer, |
| + buffer_len, |
| + Isolate::Current(), |
| + zone.GetZone()); |
| + Capability& obj = Capability::Handle(); |
| + obj ^= reader.ReadObject(); |
| + |
| + EXPECT_STREQ(12345, obj.Id()); |
| + |
| + // Read object back from the snapshot into a C structure. |
| + ApiNativeScope scope; |
| + ApiMessageReader api_reader(buffer, buffer_len, &zone_allocator); |
| + Dart_CObject* root = api_reader.ReadMessage(); |
| + EXPECT_NOTNULL(root); |
| + EXPECT_EQ(Dart_CObject_kCapability, root->type); |
| + int64_t id = root->value.as_capability.id; |
| + EXPECT_EQ(12345, id); |
| + CheckEncodeDecodeMessage(root); |
|
siva
2015/07/30 19:44:06
You should probably also have a case similar to th
turnidge
2015/07/30 21:04:13
Yes, that's what CheckEncodeDecodeMessage does.
|
| +} |
| + |
| + |
| TEST_CASE(SerializeBigint) { |
| StackZone zone(Isolate::Current()); |