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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 9169063: Add support for native ports in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Patch Set Four Rules Created 8 years, 11 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
Index: runtime/vm/dart_api_impl_test.cc
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 3603)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -2748,6 +2748,46 @@
}
+void NewNativePort_send123(Dart_Port dest_port_id,
+ Dart_Port reply_port_id,
+ uint8_t* data) {
+ intptr_t response = 123;
+ Dart_PostIntArray(reply_port_id, 1, &response);
+}
+
+
+TEST_CASE(NewNativePort) {
+ const char* kScriptChars =
+ "void callPort(SendPort port) {\n"
+ " port.call(null).receive((message, replyTo) {\n"
+ " throw new Exception(message[0]);\n"
+ " });\n"
+ "}\n";
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+ Dart_Port port_id =
+ Dart_NewNativePort("Port123", NewNativePort_send123, true);
siva 2012/01/28 00:21:05 For completeness should we make this test case a U
turnidge 2012/01/31 20:04:31 I don't understand why this helps. On 2012/01/28
siva 2012/02/01 00:38:56 This ties back to my comment regarding Dart_NewNat
turnidge 2012/02/01 18:51:26 I now test in both configurations.
+
+ Dart_Handle send_port = Dart_NewSendPort(port_id);
+ EXPECT_VALID(send_port);
+
+ Dart_Handle dart_args[1];
+ dart_args[0] = send_port;
+ Dart_Handle result = Dart_InvokeStatic(lib,
+ Dart_NewString(""),
+ Dart_NewString("callPort"),
+ 1,
+ dart_args);
+ EXPECT_VALID(result);
+ result = Dart_RunLoop();
+ EXPECT(Dart_IsError(result));
+ EXPECT(Dart_ErrorHasException(result));
+ EXPECT_SUBSTRING("Exception: 123\n", Dart_GetError(result));
+
+ // Delete the native port.
+ EXPECT(Dart_CloseNativePort(port_id));
+}
+
+
static bool RunLoopTestCallback(const char* name_prefix,
void* data, char** error) {
const char* kScriptChars =

Powered by Google App Engine
This is Rietveld 408576698