Adds PeerConnection scenario test framework.

Bug: webrtc:10839
Change-Id: If67eeb680d016d66c69d8e761a88c240e4931a5d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147276
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28754}
This commit is contained in:
Sebastian Jansson
2019-08-05 11:11:58 +02:00
committed by Commit Bot
parent 139f4dc7ac
commit ad5c4accad
17 changed files with 1050 additions and 6 deletions

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "test/peer_scenario/sdp_callbacks.h"
#include <utility>
namespace webrtc {
namespace test {
webrtc_sdp_obs_impl::SdpSetObserversInterface* SdpSetObserver(
std::function<void()> callback) {
class SdpSetObserver : public webrtc_sdp_obs_impl::SdpSetObserversInterface {
public:
explicit SdpSetObserver(std::function<void()> callback)
: callback_(std::move(callback)) {}
void OnSuccess() override { callback_(); }
void OnFailure(RTCError error) override {
RTC_NOTREACHED() << error.message();
}
void OnSetRemoteDescriptionComplete(RTCError error) override {
RTC_CHECK(error.ok()) << error.message();
callback_();
}
std::function<void()> callback_;
};
return new rtc::RefCountedObject<SdpSetObserver>(std::move(callback));
}
CreateSessionDescriptionObserver* SdpCreateObserver(
std::function<void(SessionDescriptionInterface*)> callback) {
class SdpCreateObserver : public CreateSessionDescriptionObserver {
public:
explicit SdpCreateObserver(decltype(callback) callback)
: callback_(std::move(callback)) {}
void OnSuccess(SessionDescriptionInterface* desc) override {
callback_(desc);
}
void OnFailure(RTCError error) override {
RTC_NOTREACHED() << error.message();
}
decltype(callback) callback_;
};
return new rtc::RefCountedObject<SdpCreateObserver>(std::move(callback));
}
} // namespace test
} // namespace webrtc