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..410d40600dd048dae2f0b45d87429fba4e496597 100644 |
| --- a/ppapi/tests/test_transport.cc |
| +++ b/ppapi/tests/test_transport.cc |
| @@ -103,11 +103,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(SetConfig); |
| + 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 +167,42 @@ std::string TestTransport::TestCreate() { |
| PASS(); |
| } |
| +std::string TestTransport::TestSetConfig() { |
| + RUN_SUBTEST(InitTargets("udp")); |
| + |
| + const char kEmptyConfig[] = "{}"; |
| + ASSERT_EQ(transport1_->SetConfig(kEmptyConfig), PP_OK); |
| + |
| + const char kTestConfig1[] = |
| + "{\"stunServer\": [\"stun1.a.com:31323\", \"stun2.a.com:54324\"]," |
| + "\"relayServer\": [\"relay.google.com\", \"relay.google.com\"]," |
| + "\"relayToken\": \"34t34f234f12\"," |
| + "\"tcpReceiveWindow\": 32768," |
| + "\"tcpSendWindow\": 32768,}"; |
| + ASSERT_EQ(transport1_->SetConfig(kTestConfig1), PP_OK); |
| + |
| + const char kTestConfig2[] = |
| + "{\"stunServer\": \"stun1.a.com:31323\"," |
| + "\"relayServer\": \"relay.google.com\"," |
| + "\"relayToken\": \"34t34f234f12\"}"; |
| + ASSERT_EQ(transport1_->SetConfig(kTestConfig2), PP_OK); |
| + |
| + const char kInvalidConfig[] = |
| + "{\"stunServer\": \"stun1.a.com:31323\"," |
| + "\"relayServer\": 44," |
| + "\"relayToken\": \"34t34f234f12\"}"; |
| + ASSERT_EQ(transport1_->SetConfig(kInvalidConfig), PP_ERROR_BADARGUMENT); |
| + |
| + RUN_SUBTEST(Connect()); |
| + |
| + // SetConfig() should fail after we've connected. |
| + ASSERT_EQ(transport1_->SetConfig(kEmptyConfig), PP_ERROR_FAILED); |
| + |
| + Clean(); |
| + |
| + PASS(); |
| +} |
| + |
| std::string TestTransport::TestConnect() { |
| RUN_SUBTEST(InitTargets("udp")); |
| RUN_SUBTEST(Connect()); |
| @@ -211,8 +248,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); |
|
Sergey Ulanov
2011/08/22 23:25:10
I changed this code and removed timeout in TestSen
|
| + ASSERT_EQ(timeout_cb.WaitForResult(), PP_OK); |
| ASSERT_TRUE(reader.errors().size() == 0); |
| ASSERT_TRUE(reader.received().size() > 0); |
| @@ -235,7 +273,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 +296,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); |