Chromium Code Reviews| Index: ppapi/tests/test_transport.cc |
| diff --git a/ppapi/tests/test_transport.cc b/ppapi/tests/test_transport.cc |
| index 1295f75518a43274bf944b2953f13c5b06de339c..79c48dd6a660ef9c67e9493a1e179d98e4942178 100644 |
| --- a/ppapi/tests/test_transport.cc |
| +++ b/ppapi/tests/test_transport.cc |
| @@ -13,9 +13,10 @@ |
| #include "ppapi/c/dev/ppb_testing_dev.h" |
| #include "ppapi/c/pp_errors.h" |
| #include "ppapi/cpp/completion_callback.h" |
| +#include "ppapi/cpp/dev/transport_dev.h" |
| #include "ppapi/cpp/instance.h" |
| #include "ppapi/cpp/module.h" |
| -#include "ppapi/cpp/dev/transport_dev.h" |
| +#include "ppapi/cpp/var.h" |
| #include "ppapi/tests/test_utils.h" |
| #include "ppapi/tests/testing_instance.h" |
| @@ -103,11 +104,12 @@ bool TestTransport::Init() { |
| void TestTransport::RunTest() { |
| RUN_TEST(Create); |
| - RUN_TEST(Connect); |
| - RUN_TEST_FORCEASYNC(SendDataUdp); |
| - RUN_TEST(SendDataTcp); |
| - RUN_TEST(ConnectAndCloseUdp); |
| - RUN_TEST(ConnectAndCloseTcp); |
| + RUN_TEST_FORCEASYNC_AND_NOT(Connect); |
| + RUN_TEST(SetProperty); |
| + RUN_TEST_FORCEASYNC_AND_NOT(SendDataUdp); |
| + RUN_TEST_FORCEASYNC_AND_NOT(SendDataTcp); |
| + RUN_TEST_FORCEASYNC_AND_NOT(ConnectAndCloseUdp); |
| + RUN_TEST_FORCEASYNC_AND_NOT(ConnectAndCloseTcp); |
| } |
| std::string TestTransport::InitTargets(const char* proto) { |
| @@ -166,6 +168,45 @@ std::string TestTransport::TestCreate() { |
| PASS(); |
| } |
| +std::string TestTransport::TestSetProperty() { |
| + RUN_SUBTEST(InitTargets("tcp")); |
| + |
| + // Try settings STUN and Relay properties. |
| + ASSERT_EQ(transport1_->SetProperty( |
| + PP_TRANSPORTPROPERTY_STUN_SERVER, |
| + pp::Var("stun1.a.google.com:31323,stun2.a.google.com:54324")), PP_OK); |
|
brettw
2011/08/25 16:48:43
Does example.com also make sense for these tests?
Sergey Ulanov
2011/08/25 17:36:53
Done.
|
| + |
| + ASSERT_EQ(transport1_->SetProperty( |
| + PP_TRANSPORTPROPERTY_RELAY_SERVER, |
| + pp::Var("ralay1.a.google.com:31323,relay2.a.google.com:54324")), PP_OK); |
| + |
| + ASSERT_EQ(transport1_->SetProperty( |
| + PP_TRANSPORTPROPERTY_RELAY_TOKEN, |
| + pp::Var("INVALID_TOKEN")), PP_OK); |
| + |
| + // Try changing TCP window size. |
| + ASSERT_EQ(transport1_->SetProperty(PP_TRANSPORTPROPERTY_TCP_RECEIVE_WINDOW, |
| + pp::Var(65536)), PP_OK); |
| + ASSERT_EQ(transport1_->SetProperty(PP_TRANSPORTPROPERTY_TCP_RECEIVE_WINDOW, |
| + pp::Var(10000000)), PP_ERROR_BADARGUMENT); |
| + |
| + ASSERT_EQ(transport1_->SetProperty(PP_TRANSPORTPROPERTY_TCP_SEND_WINDOW, |
| + pp::Var(65536)), PP_OK); |
| + ASSERT_EQ(transport1_->SetProperty(PP_TRANSPORTPROPERTY_TCP_SEND_WINDOW, |
| + pp::Var(10000000)), PP_ERROR_BADARGUMENT); |
| + |
| + RUN_SUBTEST(Connect()); |
| + |
| + // SetProperty() should fail after we've connected. |
| + ASSERT_EQ(transport1_->SetProperty( |
| + PP_TRANSPORTPROPERTY_STUN_SERVER, |
| + pp::Var("stun1.a.google.com:31323")), PP_ERROR_FAILED); |
| + |
| + Clean(); |
| + |
| + PASS(); |
| +} |
| + |
| std::string TestTransport::TestConnect() { |
| RUN_SUBTEST(InitTargets("udp")); |
| RUN_SUBTEST(Connect()); |
| @@ -211,8 +252,9 @@ std::string TestTransport::TestSendDataUdp() { |
| } |
| // Limit waiting time. |
| - pp::Module::Get()->core()->CallOnMainThread(kUdpWaitTimeMs, done_cb); |
| - ASSERT_EQ(done_cb.WaitForResult(), PP_OK); |
| + TestCompletionCallback timeout_cb(instance_->pp_instance()); |
| + pp::Module::Get()->core()->CallOnMainThread(kUdpWaitTimeMs, timeout_cb); |
| + ASSERT_EQ(timeout_cb.WaitForResult(), PP_OK); |
| ASSERT_TRUE(reader.errors().size() == 0); |
| ASSERT_TRUE(reader.received().size() > 0); |
| @@ -235,7 +277,6 @@ std::string TestTransport::TestSendDataTcp() { |
| RUN_SUBTEST(Connect()); |
| const int kTcpSendSize = 100000; |
| - const int kTimeoutMs = 20000; // 20 seconds. |
| TestCompletionCallback done_cb(instance_->pp_instance()); |
| StreamReader reader(transport1_.get(), kTcpSendSize, |
| @@ -259,8 +300,6 @@ std::string TestTransport::TestSendDataTcp() { |
| pos += result; |
| } |
| - // Limit waiting time. |
| - pp::Module::Get()->core()->CallOnMainThread(kTimeoutMs, done_cb); |
| ASSERT_EQ(done_cb.WaitForResult(), PP_OK); |
| ASSERT_TRUE(reader.errors().size() == 0); |