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

Unified Diff: runtime/vm/port_test.cc

Issue 8588040: Add a mid-sized integration test for the Dart Embedding Api which (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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/port_test.cc
===================================================================
--- runtime/vm/port_test.cc (revision 1518)
+++ runtime/vm/port_test.cc (working copy)
@@ -11,6 +11,13 @@
namespace dart {
+// Intercept the create port callback and remember which port was created.
+static Dart_Port saved_create_port = 0;
+static void MyCreatePortCallback(Dart_Isolate dart_isolate,
+ Dart_Port port) {
+ saved_create_port = port;
+}
+
// Intercept the post message callback and just store a copy of the message.
static const int kMaxSavedMsg = 80;
static char saved_msg[kMaxSavedMsg];
@@ -27,16 +34,18 @@
// Intercept the close port callback and remember which port was closed.
-static Dart_Port saved_port = 0;
+static Dart_Port saved_close_port = 0;
static void MyClosePortCallback(Dart_Isolate dart_isolate,
Dart_Port port) {
- saved_port = port;
+ saved_close_port = port;
}
static void InitPortMapTest() {
- Dart_SetMessageCallbacks(&MyPostMessageCallback, &MyClosePortCallback);
- saved_port = 0;
+ Dart_SetMessageCallbacks(
+ &MyCreatePortCallback, &MyPostMessageCallback, &MyClosePortCallback);
+ saved_create_port = 0;
+ saved_close_port = 0;
saved_msg[0] = '\0';
}
@@ -47,11 +56,14 @@
EXPECT_NE(0, port);
EXPECT(PortMap::IsActivePort(port));
+ // Embedder was notified of port creation.
+ EXPECT_EQ(port, saved_create_port);
+
PortMap::ClosePort(port);
EXPECT(!PortMap::IsActivePort(port));
// Embedder was notified of port closure.
- EXPECT_EQ(port, saved_port);
+ EXPECT_EQ(port, saved_close_port);
}
@@ -68,12 +80,12 @@
PortMap::ClosePort(port1);
EXPECT(!PortMap::IsActivePort(port1));
EXPECT(PortMap::IsActivePort(port2));
- EXPECT_EQ(port1, saved_port);
+ EXPECT_EQ(port1, saved_close_port);
PortMap::ClosePort(port2);
EXPECT(!PortMap::IsActivePort(port1));
EXPECT(!PortMap::IsActivePort(port2));
- EXPECT_EQ(port2, saved_port);
+ EXPECT_EQ(port2, saved_close_port);
}
@@ -90,7 +102,7 @@
EXPECT(!PortMap::IsActivePort(port2));
// Embedder is notified to close all ports as well.
- EXPECT_EQ(kCloseAllPorts, saved_port);
+ EXPECT_EQ(kCloseAllPorts, saved_close_port);
}

Powered by Google App Engine
This is Rietveld 408576698