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

Unified Diff: device/usb/mock_usb_service.cc

Issue 1144493003: Extract //device/usb mocks so that they can be shared. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android and GN builds for real. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/usb/mock_usb_service.h ('k') | device/usb/usb.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/mock_usb_service.cc
diff --git a/device/usb/mock_usb_service.cc b/device/usb/mock_usb_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..91a846ab1b4975a0a98dc1fd1227e137e2adc0d2
--- /dev/null
+++ b/device/usb/mock_usb_service.cc
@@ -0,0 +1,41 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/usb/mock_usb_service.h"
+
+#include "device/usb/usb_device.h"
+
+namespace device {
+
+MockUsbService::MockUsbService() {
+}
+
+MockUsbService::~MockUsbService() {
+}
+
+void MockUsbService::AddDevice(scoped_refptr<UsbDevice> device) {
+ devices_[device->unique_id()] = device;
+ NotifyDeviceAdded(device);
+}
+
+void MockUsbService::RemoveDevice(scoped_refptr<UsbDevice> device) {
+ devices_.erase(device->unique_id());
+ UsbService::NotifyDeviceRemoved(device);
+}
+
+scoped_refptr<UsbDevice> MockUsbService::GetDeviceById(uint32 unique_id) {
+ auto it = devices_.find(unique_id);
+ EXPECT_TRUE(it != devices_.end());
+ return it->second;
+}
+
+void MockUsbService::GetDevices(const GetDevicesCallback& callback) {
+ std::vector<scoped_refptr<UsbDevice>> devices;
+ for (const auto& map_entry : devices_) {
+ devices.push_back(map_entry.second);
+ }
+ callback.Run(devices);
+}
+
+} // namespace device
« no previous file with comments | « device/usb/mock_usb_service.h ('k') | device/usb/usb.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698