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

Side by Side Diff: device/hid/hid_connection_unittest.cc

Issue 656583003: Fix type truncation warnings in HID code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 6 years, 2 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 | « device/hid/hid_connection_linux.cc ('k') | device/hid/hid_connection_win.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) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 }; 151 };
152 152
153 TEST_F(HidConnectionTest, ReadWrite) { 153 TEST_F(HidConnectionTest, ReadWrite) {
154 if (!UsbTestGadget::IsTestEnabled()) return; 154 if (!UsbTestGadget::IsTestEnabled()) return;
155 155
156 TestConnectCallback connect_callback; 156 TestConnectCallback connect_callback;
157 service_->Connect(device_id_, connect_callback.callback()); 157 service_->Connect(device_id_, connect_callback.callback());
158 scoped_refptr<HidConnection> conn = connect_callback.WaitForConnection(); 158 scoped_refptr<HidConnection> conn = connect_callback.WaitForConnection();
159 ASSERT_TRUE(conn.get()); 159 ASSERT_TRUE(conn.get());
160 160
161 for (int i = 0; i < 8; ++i) { 161 const char kBufferSize = 9;
162 scoped_refptr<IOBufferWithSize> buffer(new IOBufferWithSize(9)); 162 for (char i = 0; i < 8; ++i) {
163 scoped_refptr<IOBufferWithSize> buffer(new IOBufferWithSize(kBufferSize));
163 buffer->data()[0] = 0; 164 buffer->data()[0] = 0;
164 for (int j = 1; j < buffer->size(); ++j) { 165 for (char j = 1; j < kBufferSize; ++j) {
165 buffer->data()[j] = i + j - 1; 166 buffer->data()[j] = i + j - 1;
166 } 167 }
167 168
168 TestIoCallback write_callback; 169 TestIoCallback write_callback;
169 conn->Write(buffer, buffer->size(), write_callback.write_callback()); 170 conn->Write(buffer, buffer->size(), write_callback.write_callback());
170 ASSERT_TRUE(write_callback.WaitForResult()); 171 ASSERT_TRUE(write_callback.WaitForResult());
171 172
172 TestIoCallback read_callback; 173 TestIoCallback read_callback;
173 conn->Read(read_callback.read_callback()); 174 conn->Read(read_callback.read_callback());
174 ASSERT_TRUE(read_callback.WaitForResult()); 175 ASSERT_TRUE(read_callback.WaitForResult());
175 ASSERT_EQ(9UL, read_callback.size()); 176 ASSERT_EQ(9UL, read_callback.size());
176 ASSERT_EQ(0, read_callback.buffer()->data()[0]); 177 ASSERT_EQ(0, read_callback.buffer()->data()[0]);
177 for (int j = 1; j < buffer->size(); ++j) { 178 for (char j = 1; j < kBufferSize; ++j) {
178 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]); 179 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]);
179 } 180 }
180 } 181 }
181 182
182 conn->Close(); 183 conn->Close();
183 } 184 }
184 185
185 } // namespace device 186 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_connection_linux.cc ('k') | device/hid/hid_connection_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698