Commit 5183c428 authored by hta's avatar hta Committed by Commit bot

Reland of Remove MockConstraints

Reason for revert:
Re-landing with fixed tests.

Original rollback description:
> Revert of Remove MockConstraints (patchset #1 id:1 of https://codereview.chromium.org/1605513002/ )
>
> Reason for revert:
> Appears to be causing fast/mediastream/RTCPeerConnection.html to fail across all bots.

Original issue's description:

Remove MockConstraints

The purpose of the MockConstraints class was to verify that only legal
constraint names were passed. This is now done inside Blink
in MediaConstraintsImpl.cpp, so this class isn't needed any more.

BUG=543997

Review URL: https://codereview.chromium.org/1614733002

Cr-Commit-Position: refs/heads/master@{#370729}
parent 4503ca76
...@@ -31,8 +31,6 @@ component("test_runner") { ...@@ -31,8 +31,6 @@ component("test_runner") {
"gc_controller.h", "gc_controller.h",
"mock_color_chooser.cc", "mock_color_chooser.cc",
"mock_color_chooser.h", "mock_color_chooser.h",
"mock_constraints.cc",
"mock_constraints.h",
"mock_credential_manager_client.cc", "mock_credential_manager_client.cc",
"mock_credential_manager_client.h", "mock_credential_manager_client.h",
"mock_grammar_check.cc", "mock_grammar_check.cc",
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/test_runner/mock_constraints.h"
#include <stddef.h>
#include "third_party/WebKit/public/platform/WebMediaConstraints.h"
#include "third_party/WebKit/public/platform/WebString.h"
using blink::WebMediaConstraint;
using blink::WebMediaConstraints;
using blink::WebString;
using blink::WebVector;
namespace test_runner {
namespace {
bool IsSupported(const WebString& constraint) {
return constraint == "valid_and_supported_1" ||
constraint == "valid_and_supported_2";
}
bool IsValid(const WebString& constraint) {
return IsSupported(constraint) || constraint == "valid_but_unsupported_1" ||
constraint == "valid_but_unsupported_2";
}
} // namespace
bool MockConstraints::VerifyConstraints(const WebMediaConstraints& constraints,
WebString* failed_constraint) {
WebVector<WebMediaConstraint> mandatory_constraints;
constraints.getMandatoryConstraints(mandatory_constraints);
if (mandatory_constraints.size()) {
for (size_t i = 0; i < mandatory_constraints.size(); ++i) {
const WebMediaConstraint& curr = mandatory_constraints[i];
if (!IsSupported(curr.m_name) || curr.m_value != "1") {
if (failed_constraint)
*failed_constraint = curr.m_name;
return false;
}
}
}
WebVector<WebMediaConstraint> optional_constraints;
constraints.getOptionalConstraints(optional_constraints);
if (optional_constraints.size()) {
for (size_t i = 0; i < optional_constraints.size(); ++i) {
const WebMediaConstraint& curr = optional_constraints[i];
if (!IsValid(curr.m_name) || curr.m_value != "0") {
if (failed_constraint)
*failed_constraint = curr.m_name;
return false;
}
}
}
return true;
}
} // namespace test_runner
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_TEST_RUNNER_MOCK_CONSTRAINTS_H_
#define COMPONENTS_TEST_RUNNER_MOCK_CONSTRAINTS_H_
namespace blink {
class WebMediaConstraints;
class WebString;
}
namespace test_runner {
class MockConstraints {
public:
static bool VerifyConstraints(const blink::WebMediaConstraints& constraints,
blink::WebString* failed_constraint = 0);
};
} // namespace test_runner
#endif // COMPONENTS_TEST_RUNNER_MOCK_CONSTRAINTS_H_
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "components/test_runner/mock_constraints.h"
#include "components/test_runner/web_test_delegate.h" #include "components/test_runner/web_test_delegate.h"
#include "third_party/WebKit/public/platform/WebMediaConstraints.h" #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
#include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h" #include "third_party/WebKit/public/platform/WebMediaDeviceInfo.h"
...@@ -146,22 +145,6 @@ void MockWebUserMediaClient::requestUserMedia( ...@@ -146,22 +145,6 @@ void MockWebUserMediaClient::requestUserMedia(
return; return;
} }
WebMediaConstraints constraints = request.audioConstraints();
WebString failed_constraint;
if (!constraints.isNull() &&
!MockConstraints::VerifyConstraints(constraints, &failed_constraint)) {
delegate_->PostTask(new UserMediaRequestConstraintFailedTask(
this, request, failed_constraint));
return;
}
constraints = request.videoConstraints();
if (!constraints.isNull() &&
!MockConstraints::VerifyConstraints(constraints, &failed_constraint)) {
delegate_->PostTask(new UserMediaRequestConstraintFailedTask(
this, request, failed_constraint));
return;
}
WebMediaStream stream; WebMediaStream stream;
stream.initialize(WebVector<WebMediaStreamTrack>(), stream.initialize(WebVector<WebMediaStreamTrack>(),
WebVector<WebMediaStreamTrack>()); WebVector<WebMediaStreamTrack>());
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <stddef.h> #include <stddef.h>
#include "components/test_runner/mock_constraints.h"
#include "components/test_runner/mock_webrtc_data_channel_handler.h" #include "components/test_runner/mock_webrtc_data_channel_handler.h"
#include "components/test_runner/mock_webrtc_dtmf_sender_handler.h" #include "components/test_runner/mock_webrtc_dtmf_sender_handler.h"
#include "components/test_runner/test_interfaces.h" #include "components/test_runner/test_interfaces.h"
...@@ -165,16 +164,12 @@ MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler( ...@@ -165,16 +164,12 @@ MockWebRTCPeerConnectionHandler::MockWebRTCPeerConnectionHandler(
bool MockWebRTCPeerConnectionHandler::initialize( bool MockWebRTCPeerConnectionHandler::initialize(
const WebRTCConfiguration& configuration, const WebRTCConfiguration& configuration,
const WebMediaConstraints& constraints) { const WebMediaConstraints& constraints) {
if (MockConstraints::VerifyConstraints(constraints)) { interfaces_->GetDelegate()->PostTask(new RTCPeerConnectionStateTask(
interfaces_->GetDelegate()->PostTask(new RTCPeerConnectionStateTask( this,
this, client_,
client_, WebRTCPeerConnectionHandlerClient::ICEConnectionStateCompleted,
WebRTCPeerConnectionHandlerClient::ICEConnectionStateCompleted, WebRTCPeerConnectionHandlerClient::ICEGatheringStateComplete));
WebRTCPeerConnectionHandlerClient::ICEGatheringStateComplete)); return true;
return true;
}
return false;
} }
void MockWebRTCPeerConnectionHandler::createOffer( void MockWebRTCPeerConnectionHandler::createOffer(
......
...@@ -58,8 +58,6 @@ ...@@ -58,8 +58,6 @@
'gc_controller.h', 'gc_controller.h',
'mock_color_chooser.cc', 'mock_color_chooser.cc',
'mock_color_chooser.h', 'mock_color_chooser.h',
'mock_constraints.cc',
'mock_constraints.h',
'mock_credential_manager_client.cc', 'mock_credential_manager_client.cc',
'mock_credential_manager_client.h', 'mock_credential_manager_client.h',
'mock_grammar_check.cc', 'mock_grammar_check.cc',
......
...@@ -35,13 +35,13 @@ PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, vali ...@@ -35,13 +35,13 @@ PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, vali
PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]}); did not throw exception. PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0},{valid_and_supported_2:0}]}); did not throw exception. PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0},{valid_and_supported_2:0}]}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {optional:[{valid_but_unsupported_1:0},{valid_but_unsupported_2:0}]}); did not throw exception. PASS new webkitRTCPeerConnection(null, {optional:[{valid_but_unsupported_1:0},{valid_but_unsupported_2:0}]}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:66}}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Failed to initialize native PeerConnection.. PASS new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:66}}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Unsatisfiable constraint valid_and_supported_1.
PASS new webkitRTCPeerConnection(null, {mandatory:{invalid:1}}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Unsatisfiable constraint invalid. PASS new webkitRTCPeerConnection(null, {mandatory:{invalid:1}}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Unsatisfiable constraint invalid.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1}}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Unsatisfiable constraint valid_but_unsupported_1. PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1}}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Unsatisfiable constraint valid_but_unsupported_1.
PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Unsatisfiable constraint valid_but_unsupported_1. PASS new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Unsatisfiable constraint valid_but_unsupported_1.
PASS new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object.. PASS new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object.. PASS new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
PASS new webkitRTCPeerConnection(null, {optional:[{invalid:0}]}); threw exception NotSupportedError: Failed to construct 'RTCPeerConnection': Failed to initialize native PeerConnection.. PASS new webkitRTCPeerConnection(null, {optional:[{invalid:0}]}); did not throw exception.
PASS new webkitRTCPeerConnection(null, {valid_and_supported_1:1}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object.. PASS new webkitRTCPeerConnection(null, {valid_and_supported_1:1}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
PASS new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object.. PASS new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
PASS new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object.. PASS new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}}); threw exception TypeError: Failed to construct 'RTCPeerConnection': Malformed constraints object..
......
...@@ -52,7 +52,8 @@ shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported ...@@ -52,7 +52,8 @@ shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported
shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}});"); shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}});");
shouldThrow("new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}});"); shouldThrow("new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}});");
shouldThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]});"); shouldThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]});");
shouldThrow("new webkitRTCPeerConnection(null, {optional:[{invalid:0}]});"); // Optional constraints are ignored even if they are invalid.
shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{invalid:0}]});");
shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_1:1});"); shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_1:1});");
shouldThrow("new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1});"); shouldThrow("new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1});");
shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}});"); shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}});");
......
...@@ -354,7 +354,10 @@ static void parseOldStyleNames(const WebVector<WebMediaConstraint>& oldNames, We ...@@ -354,7 +354,10 @@ static void parseOldStyleNames(const WebVector<WebMediaConstraint>& oldNames, We
result.googPayloadPadding.setExact(toBoolean(constraint.m_value)); result.googPayloadPadding.setExact(toBoolean(constraint.m_value));
} else if (constraint.m_name.equals(kTestConstraint1) } else if (constraint.m_name.equals(kTestConstraint1)
|| constraint.m_name.equals(kTestConstraint2)) { || constraint.m_name.equals(kTestConstraint2)) {
// These constraints are only for testing parsing. Ignore them. // These constraints are only for testing parsing.
// Values 0 and 1 are legal, all others are a ConstraintError.
if (!constraint.m_value.equals("0") && !constraint.m_value.equals("1"))
errorState.throwConstraintError("Illegal value for constraint", constraint.m_name);
} else { } else {
// TODO(hta): UMA stats for unknown constraints passed. // TODO(hta): UMA stats for unknown constraints passed.
// https://crbug.com/576613 // https://crbug.com/576613
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment