Index: ppapi/tests/test_transport.cc |
diff --git a/ppapi/tests/test_transport.cc b/ppapi/tests/test_transport.cc |
index bcb7552c990f1892f8d0b6d4ac58b07d39562646..58d752433159685a1b61f138b1c22e3486d983e2 100644 |
--- a/ppapi/tests/test_transport.cc |
+++ b/ppapi/tests/test_transport.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
@@ -9,11 +9,11 @@ |
#include <string> |
#include "ppapi/c/dev/ppb_testing_dev.h" |
-#include "ppapi/c/dev/ppb_transport_dev.h" |
#include "ppapi/c/pp_errors.h" |
#include "ppapi/cpp/completion_callback.h" |
#include "ppapi/cpp/instance.h" |
#include "ppapi/cpp/module.h" |
+#include "ppapi/cpp/dev/transport_dev.h" |
#include "ppapi/tests/test_utils.h" |
#include "ppapi/tests/testing_instance.h" |
@@ -26,11 +26,42 @@ bool TestTransport::Init() { |
} |
void TestTransport::RunTest() { |
- RUN_TEST(FirstTransport); |
+ RUN_TEST(Basics); |
// TODO(juberti): more Transport tests here... |
} |
-std::string TestTransport::TestFirstTransport() { |
- // TODO(juberti): actual test |
+std::string TestTransport::TestBasics() { |
+ pp::Transport_Dev transport1(instance_, "test", ""); |
+ pp::Transport_Dev transport2(instance_, "test", ""); |
+ |
+ TestCompletionCallback connect_cb1; |
+ TestCompletionCallback connect_cb2; |
+ ASSERT_EQ(transport1.Connect(connect_cb1), PP_ERROR_WOULDBLOCK); |
+ ASSERT_EQ(transport2.Connect(connect_cb2), PP_ERROR_WOULDBLOCK); |
+ |
+ PP_Var address1; |
+ PP_Var address2; |
+ TestCompletionCallback next_address_cb1; |
+ TestCompletionCallback next_address_cb2; |
+ ASSERT_EQ(transport1.GetNextAddress(&address1, next_address_cb1), |
+ PP_ERROR_WOULDBLOCK); |
+ ASSERT_EQ(transport2.GetNextAddress(&address2, next_address_cb2), |
+ PP_ERROR_WOULDBLOCK); |
+ ASSERT_EQ(next_address_cb1.WaitForResult(), 0); |
+ ASSERT_EQ(next_address_cb2.WaitForResult(), 0); |
+ ASSERT_EQ(transport1.GetNextAddress(&address1, next_address_cb1), PP_OK); |
+ ASSERT_EQ(transport2.GetNextAddress(&address2, next_address_cb2), PP_OK); |
+ |
+ ASSERT_EQ(transport1.ReceiveRemoteAddress(address2), 0); |
+ ASSERT_EQ(transport2.ReceiveRemoteAddress(address1), 0); |
+ |
+ ASSERT_EQ(connect_cb1.WaitForResult(), 0); |
+ ASSERT_EQ(connect_cb2.WaitForResult(), 0); |
+ |
+ ASSERT_TRUE(transport1.IsWritable()); |
+ ASSERT_TRUE(transport2.IsWritable()); |
+ |
+ // TODO(sergeyu): Verify that data can be sent/received. |
+ |
PASS(); |
} |