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

Unified Diff: chrome/browser/chromeos/printer_detector/printer_detector_unittest.cc

Issue 1337413003: Match against all configurations in UsbDeviceFilter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update printer detector tests. Created 5 years, 3 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 | « no previous file | device/usb/mock_usb_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/printer_detector/printer_detector_unittest.cc
diff --git a/chrome/browser/chromeos/printer_detector/printer_detector_unittest.cc b/chrome/browser/chromeos/printer_detector/printer_detector_unittest.cc
index 8775de23aecf41c71ed12fe652c7f3f5f6c786aa..181cc2ec20e7e8ef4515262719cd94e6cf262b33 100644
--- a/chrome/browser/chromeos/printer_detector/printer_detector_unittest.cc
+++ b/chrome/browser/chromeos/printer_detector/printer_detector_unittest.cc
@@ -19,9 +19,9 @@
#include "components/user_manager/fake_user_manager.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "device/core/device_client.h"
+#include "device/usb/mock_usb_device.h"
#include "device/usb/mock_usb_service.h"
#include "device/usb/usb_descriptors.h"
-#include "device/usb/usb_device.h"
#include "device/usb/usb_service.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension_builder.h"
@@ -45,43 +45,6 @@ const char kPrinterAppExistsDelegateIDTemplate[] =
const char kPrinterAppNotFoundDelegateIDTemplate[] =
"system.printer.no_printer_provider_found/%s:%s";
-class FakeUsbDevice : public device::UsbDevice {
- public:
- FakeUsbDevice(uint16 vendor_id, uint16 product_id, uint8 interface_class)
- : device::UsbDevice(vendor_id,
- product_id,
- base::ASCIIToUTF16("Google"),
- base::ASCIIToUTF16("A product"),
- base::ASCIIToUTF16("")) {
- config_.reset(new device::UsbConfigDescriptor);
- device::UsbInterfaceDescriptor interface;
- interface.interface_number = 1;
- interface.interface_class = interface_class;
- config_->interfaces.push_back(interface);
- }
-
- private:
- ~FakeUsbDevice() override {}
-
- // device::UsbDevice overrides:
- void Open(const OpenCallback& callback) override {
- ADD_FAILURE() << "Not reached";
- }
-
- bool Close(scoped_refptr<device::UsbDeviceHandle> handle) override {
- ADD_FAILURE() << "Not reached";
- return false;
- }
-
- const device::UsbConfigDescriptor* GetActiveConfiguration() override {
- return config_.get();
- }
-
- scoped_ptr<device::UsbConfigDescriptor> config_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeUsbDevice);
-};
-
class FakeDeviceClient : public device::DeviceClient {
public:
FakeDeviceClient() : usb_service_(nullptr) {}
@@ -152,8 +115,13 @@ class PrinterDetectorAppSearchEnabledTest : public testing::Test {
void InvokeUsbAdded(uint16 vendor_id,
uint16 product_id,
uint8 interface_class) {
+ device::UsbInterfaceDescriptor interface;
+ interface.interface_number = 1;
+ interface.interface_class = interface_class;
+ device::UsbConfigDescriptor config;
+ config.interfaces.push_back(interface);
usb_service_.AddDevice(
- new FakeUsbDevice(vendor_id, product_id, interface_class));
+ new device::MockUsbDevice(vendor_id, product_id, config));
}
// Creates a test extension with the provided permissions.
« no previous file with comments | « no previous file | device/usb/mock_usb_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698