| Index: content/browser/renderer_host/media/device_request_message_filter_unittest.cc
|
| ===================================================================
|
| --- content/browser/renderer_host/media/device_request_message_filter_unittest.cc (revision 232998)
|
| +++ content/browser/renderer_host/media/device_request_message_filter_unittest.cc (working copy)
|
| @@ -6,6 +6,7 @@
|
| #include "content/browser/renderer_host/media/device_request_message_filter.h"
|
| #include "content/browser/renderer_host/media/media_stream_manager.h"
|
| #include "content/common/media/media_stream_messages.h"
|
| +#include "content/public/browser/media_device_id.h"
|
| #include "content/public/test/mock_resource_context.h"
|
| #include "content/public/test/test_browser_thread.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| @@ -117,6 +118,11 @@
|
| host_->requested_devices().size());
|
|
|
| EXPECT_EQ(kRequestId, host_->received_id());
|
| + // Check to make sure no devices have raw ids.
|
| + EXPECT_FALSE(DoesContainRawIds(host_->requested_devices()));
|
| +
|
| + // Check to make sure every GUID produced matches a raw device id.
|
| + EXPECT_TRUE(DoesEveryDeviceMapToRawId(host_->requested_devices(), origin));
|
| }
|
|
|
| bool AreLabelsPresent(MediaStreamType type) {
|
| @@ -193,6 +199,48 @@
|
| host_->DevicesEnumerated(kVideoLabel, physical_video_devices_);
|
| }
|
|
|
| + bool DoesContainRawIds(const StreamDeviceInfoArray& devices) {
|
| + for (size_t i = 0; i < devices.size(); i++) {
|
| + for (size_t j = 0; j < physical_audio_devices_.size(); ++j) {
|
| + if (physical_audio_devices_[j].device.id == devices[i].device.id)
|
| + return true;
|
| + }
|
| + for (size_t j = 0; j < physical_video_devices_.size(); ++j) {
|
| + if (physical_video_devices_[j].device.id == devices[i].device.id)
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + bool DoesEveryDeviceMapToRawId(const StreamDeviceInfoArray& devices,
|
| + const GURL& origin) {
|
| + for (size_t i = 0; i < devices.size(); i++) {
|
| + bool found_match = false;
|
| + for (size_t j = 0; j < physical_audio_devices_.size(); ++j) {
|
| + if (content::DoesMediaDeviceIDMatchHMAC(
|
| + origin,
|
| + devices[i].device.id,
|
| + physical_audio_devices_[j].device.id)) {
|
| + EXPECT_FALSE(found_match);
|
| + found_match = true;
|
| + }
|
| + }
|
| + for (size_t j = 0; j < physical_video_devices_.size(); ++j) {
|
| + if (content::DoesMediaDeviceIDMatchHMAC(
|
| + origin,
|
| + devices[i].device.id,
|
| + physical_video_devices_[j].device.id)) {
|
| + EXPECT_FALSE(found_match);
|
| + found_match = true;
|
| + }
|
| + }
|
| + if (!found_match)
|
| + return false;
|
| + }
|
| + return true;
|
| + }
|
| +
|
| int next_device_id_;
|
| };
|
|
|
|
|