OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/usb/usb_chooser_controller.h" | 10 #include "chrome/browser/usb/usb_chooser_controller.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 mock_usb_chooser_view_.reset(new MockUsbChooserView()); | 57 mock_usb_chooser_view_.reset(new MockUsbChooserView()); |
58 usb_chooser_controller_->set_view(mock_usb_chooser_view_.get()); | 58 usb_chooser_controller_->set_view(mock_usb_chooser_view_.get()); |
59 } | 59 } |
60 | 60 |
61 protected: | 61 protected: |
62 scoped_refptr<device::MockUsbDevice> CreateMockUsbDevice( | 62 scoped_refptr<device::MockUsbDevice> CreateMockUsbDevice( |
63 const std::string& product_string, | 63 const std::string& product_string, |
64 const std::string& serial_number) { | 64 const std::string& serial_number) { |
65 scoped_refptr<device::MockUsbDevice> device(new device::MockUsbDevice( | 65 scoped_refptr<device::MockUsbDevice> device(new device::MockUsbDevice( |
66 0, 1, "Google", product_string, serial_number)); | 66 0, 1, "Google", product_string, serial_number)); |
67 std::unique_ptr<device::WebUsbAllowedOrigins> webusb_allowed_origins( | |
68 new device::WebUsbAllowedOrigins()); | |
69 webusb_allowed_origins->origins.push_back(GURL(kDefaultTestUrl)); | |
70 device->set_webusb_allowed_origins(std::move(webusb_allowed_origins)); | |
71 return device; | 67 return device; |
72 } | 68 } |
73 | 69 |
74 device::MockDeviceClient device_client_; | 70 device::MockDeviceClient device_client_; |
75 std::unique_ptr<UsbChooserController> usb_chooser_controller_; | 71 std::unique_ptr<UsbChooserController> usb_chooser_controller_; |
76 std::unique_ptr<MockUsbChooserView> mock_usb_chooser_view_; | 72 std::unique_ptr<MockUsbChooserView> mock_usb_chooser_view_; |
77 | 73 |
78 private: | 74 private: |
79 DISALLOW_COPY_AND_ASSIGN(UsbChooserControllerTest); | 75 DISALLOW_COPY_AND_ASSIGN(UsbChooserControllerTest); |
80 }; | 76 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 EXPECT_EQ(base::ASCIIToUTF16("a (001)"), | 147 EXPECT_EQ(base::ASCIIToUTF16("a (001)"), |
152 usb_chooser_controller_->GetOption(0)); | 148 usb_chooser_controller_->GetOption(0)); |
153 EXPECT_EQ(base::ASCIIToUTF16("b"), usb_chooser_controller_->GetOption(1)); | 149 EXPECT_EQ(base::ASCIIToUTF16("b"), usb_chooser_controller_->GetOption(1)); |
154 EXPECT_EQ(base::ASCIIToUTF16("a (002)"), | 150 EXPECT_EQ(base::ASCIIToUTF16("a (002)"), |
155 usb_chooser_controller_->GetOption(2)); | 151 usb_chooser_controller_->GetOption(2)); |
156 | 152 |
157 device_client_.usb_service()->RemoveDevice(device_a_1); | 153 device_client_.usb_service()->RemoveDevice(device_a_1); |
158 EXPECT_EQ(base::ASCIIToUTF16("b"), usb_chooser_controller_->GetOption(0)); | 154 EXPECT_EQ(base::ASCIIToUTF16("b"), usb_chooser_controller_->GetOption(0)); |
159 EXPECT_EQ(base::ASCIIToUTF16("a"), usb_chooser_controller_->GetOption(1)); | 155 EXPECT_EQ(base::ASCIIToUTF16("a"), usb_chooser_controller_->GetOption(1)); |
160 } | 156 } |
OLD | NEW |