OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/tests/test_transport.h" | 5 #include "ppapi/tests/test_transport.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ppapi/c/dev/ppb_testing_dev.h" | 11 #include "ppapi/c/dev/ppb_testing_dev.h" |
12 #include "ppapi/c/dev/ppb_transport_dev.h" | |
13 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
14 #include "ppapi/cpp/completion_callback.h" | 13 #include "ppapi/cpp/completion_callback.h" |
15 #include "ppapi/cpp/instance.h" | 14 #include "ppapi/cpp/instance.h" |
16 #include "ppapi/cpp/module.h" | 15 #include "ppapi/cpp/module.h" |
16 #include "ppapi/cpp/dev/transport_dev.h" | |
17 #include "ppapi/tests/test_utils.h" | 17 #include "ppapi/tests/test_utils.h" |
18 #include "ppapi/tests/testing_instance.h" | 18 #include "ppapi/tests/testing_instance.h" |
19 | 19 |
20 REGISTER_TEST_CASE(Transport); | 20 REGISTER_TEST_CASE(Transport); |
21 | 21 |
22 bool TestTransport::Init() { | 22 bool TestTransport::Init() { |
23 transport_interface_ = reinterpret_cast<PPB_Transport_Dev const*>( | 23 transport_interface_ = reinterpret_cast<PPB_Transport_Dev const*>( |
24 pp::Module::Get()->GetBrowserInterface(PPB_TRANSPORT_DEV_INTERFACE)); | 24 pp::Module::Get()->GetBrowserInterface(PPB_TRANSPORT_DEV_INTERFACE)); |
25 return transport_interface_ && InitTestingInterface(); | 25 return transport_interface_ && InitTestingInterface(); |
26 } | 26 } |
27 | 27 |
28 void TestTransport::RunTest() { | 28 void TestTransport::RunTest() { |
29 RUN_TEST(FirstTransport); | 29 RUN_TEST(Basics); |
30 // TODO(juberti): more Transport tests here... | 30 // TODO(juberti): more Transport tests here... |
31 } | 31 } |
32 | 32 |
33 std::string TestTransport::TestFirstTransport() { | 33 std::string TestTransport::TestBasics() { |
34 // TODO(juberti): actual test | 34 pp::Transport_Dev t1("test", ""), t2("test", ""); |
35 TestCompletionCallback c1, c2, gna1, gna2; | |
36 PP_Var a1, a2; | |
37 int32_t rv; | |
38 | |
39 rv = t1.Connect(c1); | |
40 if (rv != PP_ERROR_WOULDBLOCK) { | |
41 return ReportError("Transport::Connect", rv); | |
42 } | |
43 rv = t2.Connect(c2); | |
44 if (rv != PP_ERROR_WOULDBLOCK) { | |
45 return ReportError("Transport::Connect", rv); | |
46 } | |
47 rv = t1.GetNextAddress(&a1, gna1); | |
48 if (rv != PP_ERROR_WOULDBLOCK) { | |
49 return ReportError("Transport::GetNextAddress", rv); | |
50 } | |
51 rv = t2.GetNextAddress(&a2, gna2); | |
52 if (rv != PP_ERROR_WOULDBLOCK) { | |
53 return ReportError("Transport::GetNextAddress", rv); | |
54 } | |
55 rv = gna1.WaitForResult(); | |
56 if (rv != 0) { | |
57 return ReportError("Transport::GetNextAddress", rv); | |
58 } | |
59 rv = gna2.WaitForResult(); | |
60 if (rv != 0) { | |
61 return ReportError("Transport::GetNextAddress", rv); | |
62 } | |
63 rv = t1.ReceiveRemoteAddress(a2); | |
64 if (rv != 0) { | |
65 return ReportError("Transport::ReceiveRemoteAddress", rv); | |
66 } | |
67 rv = t2.ReceiveRemoteAddress(a1); | |
68 if (rv != 0) { | |
69 return ReportError("Transport::ReceiveRemoteAddress", rv); | |
70 } | |
71 rv = c1.WaitForResult(); | |
72 if (rv != 0) { | |
73 return ReportError("Transport::Connect", rv); | |
74 } | |
75 rv = c2.WaitForResult(); | |
76 if (rv != 0) { | |
77 return ReportError("Transport::Connect", rv); | |
78 } | |
79 if (!t1.IsWritable()) { | |
80 return ReportError("Transport::IsWritable", 0); | |
81 } | |
82 if (!t2.IsWritable()) { | |
83 return ReportError("Transport::IsWritable", 0); | |
84 } | |
85 /*rv = t1.Send(kTestData, sizeof(kTestData), IsWritable()) { | |
brettw
2010/12/21 21:55:50
This should be either uncommented or have a commen
| |
86 return ReportError("Transport::IsWritable", 0); | |
87 }*/ | |
35 return ""; | 88 return ""; |
36 } | 89 } |
OLD | NEW |