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

Side by Side Diff: extensions/browser/api/hid/hid_apitest.cc

Issue 943783003: Pad HID output reports on Windows to the maximum output report size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added "size" to comment. 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 | « device/hid/hid_connection_win.cc ('k') | extensions/test/data/api_test/hid/api/background.js » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "device/hid/hid_collection_info.h" 8 #include "device/hid/hid_collection_info.h"
9 #include "device/hid/hid_connection.h" 9 #include "device/hid/hid_connection.h"
10 #include "device/hid/hid_device_info.h" 10 #include "device/hid/hid_device_info.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 scoped_refptr<IOBuffer> buffer(new IOBuffer(sizeof(kResult))); 51 scoped_refptr<IOBuffer> buffer(new IOBuffer(sizeof(kResult)));
52 buffer->data()[0] = report_id; 52 buffer->data()[0] = report_id;
53 memcpy(buffer->data() + 1, kResult, sizeof(kResult) - 1); 53 memcpy(buffer->data() + 1, kResult, sizeof(kResult) - 1);
54 ThreadTaskRunnerHandle::Get()->PostTask( 54 ThreadTaskRunnerHandle::Get()->PostTask(
55 FROM_HERE, base::Bind(callback, true, buffer, sizeof(kResult))); 55 FROM_HERE, base::Bind(callback, true, buffer, sizeof(kResult)));
56 } 56 }
57 57
58 void PlatformWrite(scoped_refptr<net::IOBuffer> buffer, 58 void PlatformWrite(scoped_refptr<net::IOBuffer> buffer,
59 size_t size, 59 size_t size,
60 const WriteCallback& callback) override { 60 const WriteCallback& callback) override {
61 const char kExpected[] = "This is a HID output report."; 61 const char kExpected[] = "o-report"; // 8 bytes
62 bool result = false; 62 bool result = false;
63 if (size == sizeof(kExpected)) { 63 if (size == sizeof(kExpected)) {
64 uint8_t report_id = buffer->data()[0]; 64 uint8_t report_id = buffer->data()[0];
65 uint8_t expected_report_id = device_info()->has_report_id() ? 1 : 0; 65 uint8_t expected_report_id = device_info()->has_report_id() ? 1 : 0;
66 if (report_id == expected_report_id) { 66 if (report_id == expected_report_id) {
67 if (memcmp(buffer->data() + 1, kExpected, sizeof(kExpected) - 1) == 0) { 67 if (memcmp(buffer->data() + 1, kExpected, sizeof(kExpected) - 1) == 0) {
68 result = true; 68 result = true;
69 } 69 }
70 } 70 }
71 } 71 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Device C was not returned by chrome.hid.getDevices, the app will not get 207 // Device C was not returned by chrome.hid.getDevices, the app will not get
208 // a notification. 208 // a notification.
209 hid_service_->RemoveDevice("C"); 209 hid_service_->RemoveDevice("C");
210 // Device A was returned, the app will get a notification. 210 // Device A was returned, the app will get a notification.
211 hid_service_->RemoveDevice("A"); 211 hid_service_->RemoveDevice("A");
212 ASSERT_TRUE(result_listener.WaitUntilSatisfied()); 212 ASSERT_TRUE(result_listener.WaitUntilSatisfied());
213 EXPECT_EQ("success", result_listener.message()); 213 EXPECT_EQ("success", result_listener.message());
214 } 214 }
215 215
216 } // namespace extensions 216 } // namespace extensions
OLDNEW
« no previous file with comments | « device/hid/hid_connection_win.cc ('k') | extensions/test/data/api_test/hid/api/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698