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

Unified Diff: device/usb/mojo/device_impl_unittest.cc

Issue 1847183002: Use interface associations to check function permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit and fixed Windows build. Created 4 years, 9 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/mojo/device_impl.cc ('k') | device/usb/mojo/device_manager_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/mojo/device_impl_unittest.cc
diff --git a/device/usb/mojo/device_impl_unittest.cc b/device/usb/mojo/device_impl_unittest.cc
index 78a1f855315c2464d7c64e5507fb989cee8d6966..7f99ce1e3ec698ffb8ff9d937302b0622284ad92 100644
--- a/device/usb/mojo/device_impl_unittest.cc
+++ b/device/usb/mojo/device_impl_unittest.cc
@@ -22,7 +22,7 @@
#include "base/stl_util.h"
#include "device/usb/mock_usb_device.h"
#include "device/usb/mock_usb_device_handle.h"
-#include "device/usb/mojo/fake_permission_provider.h"
+#include "device/usb/mojo/mock_permission_provider.h"
#include "device/usb/mojo/type_converters.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "net/base/io_buffer.h"
@@ -152,6 +152,7 @@ class USBDeviceImplTest : public testing::Test {
~USBDeviceImplTest() override {}
protected:
+ MockPermissionProvider& permission_provider() { return permission_provider_; }
MockUsbDevice& mock_device() { return *mock_device_.get(); }
bool is_device_open() const { return is_device_open_; }
MockUsbDeviceHandle& mock_handle() { return *mock_handle_.get(); }
@@ -441,7 +442,7 @@ class USBDeviceImplTest : public testing::Test {
std::set<uint8_t> claimed_interfaces_;
- FakePermissionProvider permission_provider_;
+ MockPermissionProvider permission_provider_;
DISALLOW_COPY_AND_ASSIGN(USBDeviceImplTest);
};
@@ -532,6 +533,7 @@ TEST_F(USBDeviceImplTest, SetInvalidConfiguration) {
}
EXPECT_CALL(mock_handle(), SetConfiguration(42, _));
+ EXPECT_CALL(permission_provider(), HasConfigurationPermission(42, _));
{
// SetConfiguration should fail because 42 is not a valid mock
@@ -558,6 +560,7 @@ TEST_F(USBDeviceImplTest, SetValidConfiguration) {
}
EXPECT_CALL(mock_handle(), SetConfiguration(42, _));
+ EXPECT_CALL(permission_provider(), HasConfigurationPermission(42, _));
AddMockConfig(ConfigBuilder(42));
@@ -625,6 +628,7 @@ TEST_F(USBDeviceImplTest, ClaimAndReleaseInterface) {
AddMockConfig(ConfigBuilder(1).AddInterface(1, 0, 1, 2, 3));
EXPECT_CALL(mock_handle(), SetConfiguration(1, _));
+ EXPECT_CALL(permission_provider(), HasConfigurationPermission(1, _));
{
base::RunLoop loop;
@@ -634,7 +638,6 @@ TEST_F(USBDeviceImplTest, ClaimAndReleaseInterface) {
}
EXPECT_CALL(mock_device(), GetActiveConfiguration());
- EXPECT_CALL(mock_handle(), ClaimInterface(2, _));
{
// Try to claim an invalid interface and expect failure.
@@ -646,6 +649,7 @@ TEST_F(USBDeviceImplTest, ClaimAndReleaseInterface) {
EXPECT_CALL(mock_device(), GetActiveConfiguration());
EXPECT_CALL(mock_handle(), ClaimInterface(1, _));
+ EXPECT_CALL(permission_provider(), HasFunctionPermission(1, 1, _));
{
base::RunLoop loop;
@@ -731,6 +735,7 @@ TEST_F(USBDeviceImplTest, ControlTransfer) {
EXPECT_CALL(mock_device(), GetActiveConfiguration());
EXPECT_CALL(mock_handle(), SetConfiguration(1, _));
+ EXPECT_CALL(permission_provider(), HasConfigurationPermission(1, _));
{
base::RunLoop loop;
@@ -749,6 +754,7 @@ TEST_F(USBDeviceImplTest, ControlTransfer) {
EXPECT_CALL(mock_handle(),
ControlTransfer(USB_DIRECTION_INBOUND, UsbDeviceHandle::STANDARD,
UsbDeviceHandle::DEVICE, 5, 6, 7, _, _, 0, _));
+ EXPECT_CALL(permission_provider(), HasConfigurationPermission(1, _));
{
auto params = ControlTransferParams::New();
@@ -771,6 +777,7 @@ TEST_F(USBDeviceImplTest, ControlTransfer) {
EXPECT_CALL(mock_handle(),
ControlTransfer(USB_DIRECTION_OUTBOUND, UsbDeviceHandle::STANDARD,
UsbDeviceHandle::INTERFACE, 5, 6, 7, _, _, 0, _));
+ EXPECT_CALL(permission_provider(), HasFunctionPermission(7, 1, _));
{
auto params = ControlTransferParams::New();
« no previous file with comments | « device/usb/mojo/device_impl.cc ('k') | device/usb/mojo/device_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698