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

Side by Side Diff: chrome/browser/usb/usb_chooser_controller_unittest.cc

Issue 2611773004: Allow top-level frames to request any USB device. (Closed)
Patch Set: Add comments explaining how the mock devices are being used. Created 3 years, 11 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
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 void SetUp() override { 48 void SetUp() override {
49 ChromeRenderViewHostTestHarness::SetUp(); 49 ChromeRenderViewHostTestHarness::SetUp();
50 50
51 mojo::Array<device::usb::DeviceFilterPtr> device_filters; 51 mojo::Array<device::usb::DeviceFilterPtr> device_filters;
52 device::usb::ChooserService::GetPermissionCallback callback; 52 device::usb::ChooserService::GetPermissionCallback callback;
53 content::WebContentsTester* web_contents_tester = 53 content::WebContentsTester* web_contents_tester =
54 content::WebContentsTester::For(web_contents()); 54 content::WebContentsTester::For(web_contents());
55 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl)); 55 web_contents_tester->NavigateAndCommit(GURL(kDefaultTestUrl));
56 usb_chooser_controller_.reset(new UsbChooserController( 56 usb_chooser_controller_.reset(new UsbChooserController(
57 main_rfh(), std::move(device_filters), main_rfh(), callback)); 57 main_rfh(), std::move(device_filters), callback));
58 mock_usb_chooser_view_.reset(new MockUsbChooserView()); 58 mock_usb_chooser_view_.reset(new MockUsbChooserView());
59 usb_chooser_controller_->set_view(mock_usb_chooser_view_.get()); 59 usb_chooser_controller_->set_view(mock_usb_chooser_view_.get());
60 } 60 }
61 61
62 protected: 62 protected:
63 scoped_refptr<device::MockUsbDevice> CreateMockUsbDevice( 63 scoped_refptr<device::MockUsbDevice> CreateMockUsbDevice(
64 const std::string& product_string, 64 const std::string& product_string,
65 const std::string& serial_number) { 65 const std::string& serial_number) {
66 scoped_refptr<device::MockUsbDevice> device(new device::MockUsbDevice( 66 scoped_refptr<device::MockUsbDevice> device(new device::MockUsbDevice(
67 0, 1, "Google", product_string, serial_number)); 67 0, 1, "Google", product_string, serial_number));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 EXPECT_EQ(base::ASCIIToUTF16("a (001)"), 152 EXPECT_EQ(base::ASCIIToUTF16("a (001)"),
153 usb_chooser_controller_->GetOption(0)); 153 usb_chooser_controller_->GetOption(0));
154 EXPECT_EQ(base::ASCIIToUTF16("b"), usb_chooser_controller_->GetOption(1)); 154 EXPECT_EQ(base::ASCIIToUTF16("b"), usb_chooser_controller_->GetOption(1));
155 EXPECT_EQ(base::ASCIIToUTF16("a (002)"), 155 EXPECT_EQ(base::ASCIIToUTF16("a (002)"),
156 usb_chooser_controller_->GetOption(2)); 156 usb_chooser_controller_->GetOption(2));
157 157
158 device_client_.usb_service()->RemoveDevice(device_a_1); 158 device_client_.usb_service()->RemoveDevice(device_a_1);
159 EXPECT_EQ(base::ASCIIToUTF16("b"), usb_chooser_controller_->GetOption(0)); 159 EXPECT_EQ(base::ASCIIToUTF16("b"), usb_chooser_controller_->GetOption(0));
160 EXPECT_EQ(base::ASCIIToUTF16("a"), usb_chooser_controller_->GetOption(1)); 160 EXPECT_EQ(base::ASCIIToUTF16("a"), usb_chooser_controller_->GetOption(1));
161 } 161 }
OLDNEW
« no previous file with comments | « chrome/browser/usb/usb_chooser_controller.cc ('k') | chrome/browser/usb/web_usb_chooser_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698