Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(882)

Unified Diff: runtime/vm/snapshot_test.cc

Issue 1267603003: Support sending and receiving Capability objects from C code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « runtime/vm/dart_api_message.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698