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

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

Issue 14139012: PPAPI: More test cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Provide a message loop for "background thread" test so we can use a REQUIRED callback Created 7 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_tcp_socket_private_trusted.h" 5 #include "ppapi/tests/test_tcp_socket_private_trusted.h"
6 6
7 #include "ppapi/cpp/private/tcp_socket_private.h" 7 #include "ppapi/cpp/private/tcp_socket_private.h"
8 #include "ppapi/cpp/private/x509_certificate_private.h" 8 #include "ppapi/cpp/private/x509_certificate_private.h"
9 #include "ppapi/tests/testing_instance.h" 9 #include "ppapi/tests/testing_instance.h"
10 #include "ppapi/tests/test_utils.h" 10 #include "ppapi/tests/test_utils.h"
(...skipping 17 matching lines...) Expand all
28 if (!GetLocalHostPort(instance_->pp_instance(), &host_, &port_)) 28 if (!GetLocalHostPort(instance_->pp_instance(), &host_, &port_))
29 return false; 29 return false;
30 30
31 // Get the port for the SSL server. 31 // Get the port for the SSL server.
32 ssl_port_ = instance_->ssl_server_port(); 32 ssl_port_ = instance_->ssl_server_port();
33 33
34 return true; 34 return true;
35 } 35 }
36 36
37 void TestTCPSocketPrivateTrusted::RunTests(const std::string& filter) { 37 void TestTCPSocketPrivateTrusted::RunTests(const std::string& filter) {
38 RUN_TEST_FORCEASYNC_AND_NOT(GetServerCertificate, filter); 38 RUN_CALLBACK_TEST(TestTCPSocketPrivateTrusted, GetServerCertificate, filter);
39 } 39 }
40 40
41 std::string TestTCPSocketPrivateTrusted::TestGetServerCertificate() { 41 std::string TestTCPSocketPrivateTrusted::TestGetServerCertificate() {
42 pp::TCPSocketPrivate socket(instance_); 42 pp::TCPSocketPrivate socket(instance_);
43 TestCompletionCallback cb(instance_->pp_instance(), force_async_); 43 TestCompletionCallback cb(instance_->pp_instance(), callback_type());
44 44
45 int32_t rv = socket.Connect(host_.c_str(), ssl_port_, cb.GetCallback()); 45 cb.WaitForResult(
46 ASSERT_TRUE(!force_async_ || rv == PP_OK_COMPLETIONPENDING); 46 socket.Connect(host_.c_str(), ssl_port_, cb.GetCallback()));
47 if (rv == PP_OK_COMPLETIONPENDING) 47 CHECK_CALLBACK_BEHAVIOR(cb);
48 rv = cb.WaitForResult(); 48 ASSERT_EQ(PP_OK, cb.result());
49 ASSERT_EQ(PP_OK, rv);
50 49
51 rv = socket.SSLHandshake(host_.c_str(), ssl_port_, cb.GetCallback()); 50 cb.WaitForResult(
52 ASSERT_TRUE(!force_async_ || rv == PP_OK_COMPLETIONPENDING); 51 socket.SSLHandshake(host_.c_str(), ssl_port_, cb.GetCallback()));
53 if (rv == PP_OK_COMPLETIONPENDING) 52 CHECK_CALLBACK_BEHAVIOR(cb);
54 rv = cb.WaitForResult(); 53 ASSERT_EQ(PP_OK, cb.result());
55 ASSERT_EQ(PP_OK, rv);
56 54
57 const pp::X509CertificatePrivate& cert = socket.GetServerCertificate(); 55 const pp::X509CertificatePrivate& cert = socket.GetServerCertificate();
58 ASSERT_EQ( 56 ASSERT_EQ(
59 cert.GetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME).AsString(), 57 cert.GetField(PP_X509CERTIFICATE_PRIVATE_ISSUER_COMMON_NAME).AsString(),
60 "Test CA"); 58 "Test CA");
61 ASSERT_EQ( 59 ASSERT_EQ(
62 cert.GetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME).AsString(), 60 cert.GetField(PP_X509CERTIFICATE_PRIVATE_SUBJECT_COMMON_NAME).AsString(),
63 "127.0.0.1"); 61 "127.0.0.1");
64 PASS(); 62 PASS();
65 } 63 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_tcp_socket_private_disallowed.cc ('k') | ppapi/tests/test_udp_socket_private.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698