| 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);
|
| }
|
|
|
|
|
|
|