OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "device/usb/usb_device_filter.h" |
| 6 #include "extensions/common/api/printer_provider/usb_printer_manifest_data.h" |
| 7 #include "extensions/common/manifest_test.h" |
| 8 #include "extensions/common/value_builder.h" |
| 9 |
| 10 namespace extensions { |
| 11 |
| 12 class UsbPrinterManifestTest : public ManifestTest { |
| 13 public: |
| 14 UsbPrinterManifestTest() {} |
| 15 ~UsbPrinterManifestTest() override {} |
| 16 }; |
| 17 |
| 18 TEST_F(UsbPrinterManifestTest, Filters) { |
| 19 scoped_refptr<Extension> extension = |
| 20 LoadAndExpectSuccess("usb_printers_filters.json"); |
| 21 const UsbPrinterManifestData* manifest_data = |
| 22 UsbPrinterManifestData::Get(extension.get()); |
| 23 ASSERT_TRUE(manifest_data); |
| 24 EXPECT_EQ(2u, manifest_data->filters().size()); |
| 25 EXPECT_TRUE(DictionaryBuilder() |
| 26 .Set("vendorId", 1) |
| 27 .Set("productId", 2) |
| 28 .Build() |
| 29 ->Equals(manifest_data->filters()[0].ToValue().get())); |
| 30 EXPECT_TRUE(DictionaryBuilder() |
| 31 .Set("vendorId", 1) |
| 32 .Set("interfaceClass", 2) |
| 33 .Set("interfaceSubclass", 3) |
| 34 .Set("interfaceProtocol", 4) |
| 35 .Build() |
| 36 ->Equals(manifest_data->filters()[1].ToValue().get())); |
| 37 } |
| 38 |
| 39 TEST_F(UsbPrinterManifestTest, InvalidFilter) { |
| 40 LoadAndExpectError( |
| 41 "usb_printers_invalid_filter.json", |
| 42 "Only one of productId or interfaceClass may be specified."); |
| 43 } |
| 44 |
| 45 } // namespace extensions |
OLD | NEW |