webrtc/rtc_base/gunit.cc
Steve Anton 80dd7b5d68 Reland "Set session error if SetLocal/RemoteDescription ever fails"
Original change's description:
> Set session error if SetLocal/RemoteDescription ever fails
> 
> This changes SetLocalDescription/SetRemoteDescription to set a
> session error which will cause any future calls to fail early if
> there is an error when applying a session description.
> 
> This is needed since until better error recovery is implemented
> failing a call to SetLocalDescription or SetRemoteDescription
> could leave the PeerConnection in an inconsistent state.
> 
> Bug: chromium:800775
> Change-Id: If06fd73d6e902af15d072dc562bbe830d3b11ad5
> Reviewed-on: https://webrtc-review.googlesource.com/54061
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Commit-Queue: Steve Anton <steveanton@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22061}

Bug: chromium:800775
Change-Id: I0016108264e013452e9d34239c012baf23240e99
Reviewed-on: https://webrtc-review.googlesource.com/54720
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22067}
2018-02-17 02:08:19 +00:00

41 lines
1.6 KiB
C++

/*
* Copyright 2018 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 "rtc_base/gunit.h"
#include <string>
#include "rtc_base/stringutils.h"
::testing::AssertionResult AssertStartsWith(const char* str_expr,
const char* prefix_expr,
const std::string& str,
const std::string& prefix) {
if (rtc::starts_with(str.c_str(), prefix.c_str())) {
return ::testing::AssertionSuccess();
} else {
return ::testing::AssertionFailure()
<< str_expr << "\nwhich is\n\"" << str << "\"\ndoes not start with\n"
<< prefix_expr << "\nwhich is\n\"" << prefix << "\"";
}
}
::testing::AssertionResult AssertStringContains(const char* str_expr,
const char* substr_expr,
const std::string& str,
const std::string& substr) {
if (str.find(substr) != std::string::npos) {
return ::testing::AssertionSuccess();
} else {
return ::testing::AssertionFailure()
<< str_expr << "\nwhich is\n\"" << str << "\"\ndoes not contain\n"
<< substr_expr << "\nwhich is\n\"" << substr << "\"";
}
}