Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: ppapi/tests/test_transport.cc

Issue 6478018: Basic implementation of Pepper Transport API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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(instance_, "test", ""), t2(instance_, "test", "");
brettw 2011/02/10 07:19:16 I think Google style discourages multiple declarat
Sergey Ulanov 2011/02/10 21:14:54 Done. Also renamed all variables.
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) {
brettw 2011/02/10 07:19:16 test_case.h defines ASSERT_TRUE which makes this p
Sergey Ulanov 2011/02/10 21:14:54 Actullay ASSERT_EQ is more appropriate here.
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 // TODO(sergeyu): Verify that data can be sent/received.
35 PASS(); 86 PASS();
36 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698