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

Unified Diff: device/devices_app/usb/device_manager_impl_unittest.cc

Issue 1369643002: Add configuration and interface permission checks to DeviceImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new method ot Android USB mocks. 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
Index: device/devices_app/usb/device_manager_impl_unittest.cc
diff --git a/device/devices_app/usb/device_manager_impl_unittest.cc b/device/devices_app/usb/device_manager_impl_unittest.cc
index 2f25dc0ff527a722287f39bb56209e4c18969b26..d4e43c882b052fc4bfadb25c51825a592e8bd7fe 100644
--- a/device/devices_app/usb/device_manager_impl_unittest.cc
+++ b/device/devices_app/usb/device_manager_impl_unittest.cc
@@ -14,11 +14,11 @@
#include "device/core/device_client.h"
#include "device/devices_app/usb/device_impl.h"
#include "device/devices_app/usb/device_manager_impl.h"
+#include "device/devices_app/usb/fake_permission_provider.h"
#include "device/usb/mock_usb_device.h"
#include "device/usb/mock_usb_device_handle.h"
#include "device/usb/mock_usb_service.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
using ::testing::Invoke;
using ::testing::_;
@@ -28,26 +28,6 @@ namespace usb {
namespace {
-class TestPermissionProvider : public PermissionProvider {
- public:
- TestPermissionProvider(mojo::InterfaceRequest<PermissionProvider> request)
- : binding_(this, request.Pass()) {}
- ~TestPermissionProvider() override {}
-
- void HasDevicePermission(
- mojo::Array<DeviceInfoPtr> requested_devices,
- const HasDevicePermissionCallback& callback) override {
- // Permission to access all devices granted.
- mojo::Array<mojo::String> allowed_guids(requested_devices.size());
- for (size_t i = 0; i < requested_devices.size(); ++i)
- allowed_guids[i] = requested_devices[i]->guid;
- callback.Run(allowed_guids.Pass());
- }
-
- private:
- mojo::StrongBinding<PermissionProvider> binding_;
-};
-
class TestDeviceClient : public DeviceClient {
public:
TestDeviceClient() {}
@@ -76,7 +56,7 @@ class USBDeviceManagerImplTest : public testing::Test {
DeviceManagerPtr ConnectToDeviceManager() {
PermissionProviderPtr permission_provider;
- new TestPermissionProvider(mojo::GetProxy(&permission_provider));
+ permission_provider_.Bind(mojo::GetProxy(&permission_provider));
DeviceManagerPtr device_manager;
new DeviceManagerImpl(mojo::GetProxy(&device_manager),
permission_provider.Pass(),
@@ -85,6 +65,7 @@ class USBDeviceManagerImplTest : public testing::Test {
}
private:
+ FakePermissionProvider permission_provider_;
scoped_ptr<TestDeviceClient> device_client_;
scoped_ptr<base::MessageLoop> message_loop_;
};

Powered by Google App Engine
This is Rietveld 408576698