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

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

Issue 915403003: Enable size_t to int truncation warnings in PPAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ppapi_unittests win x64 Created 5 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
« no previous file with comments | « ppapi/tests/test_udp_socket.cc ('k') | ppapi/tests/test_url_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <cstring> 5 #include <cstring>
6 #include <vector> 6 #include <vector>
7 7
8 #include "ppapi/cpp/module.h" 8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/private/net_address_private.h" 9 #include "ppapi/cpp/private/net_address_private.h"
10 #include "ppapi/cpp/private/tcp_socket_private.h" 10 #include "ppapi/cpp/private/tcp_socket_private.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 PASS(); 131 PASS();
132 } 132 }
133 133
134 std::string TestUDPSocketPrivate::ReadSocket(pp::UDPSocketPrivate* socket, 134 std::string TestUDPSocketPrivate::ReadSocket(pp::UDPSocketPrivate* socket,
135 PP_NetAddress_Private* address, 135 PP_NetAddress_Private* address,
136 size_t size, 136 size_t size,
137 std::string* message) { 137 std::string* message) {
138 std::vector<char> buffer(size); 138 std::vector<char> buffer(size);
139 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 139 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
140 callback.WaitForResult( 140 callback.WaitForResult(
141 socket->RecvFrom(&buffer[0], size, callback.GetCallback())); 141 socket->RecvFrom(&buffer[0], static_cast<int32_t>(size),
142 callback.GetCallback()));
142 CHECK_CALLBACK_BEHAVIOR(callback); 143 CHECK_CALLBACK_BEHAVIOR(callback);
143 ASSERT_FALSE(callback.result() < 0); 144 ASSERT_FALSE(callback.result() < 0);
144 ASSERT_EQ(size, static_cast<size_t>(callback.result())); 145 ASSERT_EQ(size, static_cast<size_t>(callback.result()));
145 message->assign(buffer.begin(), buffer.end()); 146 message->assign(buffer.begin(), buffer.end());
146 PASS(); 147 PASS();
147 } 148 }
148 149
149 std::string TestUDPSocketPrivate::PassMessage(pp::UDPSocketPrivate* target, 150 std::string TestUDPSocketPrivate::PassMessage(pp::UDPSocketPrivate* target,
150 pp::UDPSocketPrivate* source, 151 pp::UDPSocketPrivate* source,
151 PP_NetAddress_Private* address, 152 PP_NetAddress_Private* address,
152 const std::string& message) { 153 const std::string& message) {
153 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 154 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
154 int32_t rv = source->SendTo(message.c_str(), message.size(), address, 155 int32_t rv = source->SendTo(message.c_str(),
156 static_cast<int32_t>(message.size()), address,
155 callback.GetCallback()); 157 callback.GetCallback());
156 std::string str; 158 std::string str;
157 ASSERT_SUBTEST_SUCCESS(ReadSocket(target, address, message.size(), &str)); 159 ASSERT_SUBTEST_SUCCESS(ReadSocket(target, address, message.size(), &str));
158 160
159 callback.WaitForResult(rv); 161 callback.WaitForResult(rv);
160 CHECK_CALLBACK_BEHAVIOR(callback); 162 CHECK_CALLBACK_BEHAVIOR(callback);
161 ASSERT_FALSE(callback.result() < 0); 163 ASSERT_FALSE(callback.result() < 0);
162 ASSERT_EQ(message.size(), static_cast<size_t>(callback.result())); 164 ASSERT_EQ(message.size(), static_cast<size_t>(callback.result()));
163 ASSERT_EQ(message, str); 165 ASSERT_EQ(message, str);
164 PASS(); 166 PASS();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 int32_t rv = socket.SetSocketFeature(PP_UDPSOCKETFEATURE_PRIVATE_COUNT, 252 int32_t rv = socket.SetSocketFeature(PP_UDPSOCKETFEATURE_PRIVATE_COUNT,
251 pp::Var(true)); 253 pp::Var(true));
252 ASSERT_EQ(PP_ERROR_BADARGUMENT, rv); 254 ASSERT_EQ(PP_ERROR_BADARGUMENT, rv);
253 255
254 // Try to pass incorrect feature value's type. 256 // Try to pass incorrect feature value's type.
255 rv = socket.SetSocketFeature(PP_UDPSOCKETFEATURE_PRIVATE_ADDRESS_REUSE, 257 rv = socket.SetSocketFeature(PP_UDPSOCKETFEATURE_PRIVATE_ADDRESS_REUSE,
256 pp::Var(1)); 258 pp::Var(1));
257 ASSERT_EQ(PP_ERROR_BADARGUMENT, rv); 259 ASSERT_EQ(PP_ERROR_BADARGUMENT, rv);
258 PASS(); 260 PASS();
259 } 261 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_udp_socket.cc ('k') | ppapi/tests/test_url_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698