From b5388d77489388e5a9941cca9b979f9cfb4c8f76 Mon Sep 17 00:00:00 2001 From: deadbeef Date: Fri, 24 Feb 2017 01:17:43 -0800 Subject: [PATCH] Move rtc_api_unittests into rtc_unittests. This avoids adding an additional test target. Plus, everything in rtc_api_unittests is (and likely will be) simple utility classes akin to what's already being tested in rtc_unittests. BUG=None TBR=kjellander@webrtc.org Review-Url: https://codereview.webrtc.org/2709573003 Cr-Commit-Position: refs/heads/master@{#16819} --- webrtc/BUILD.gn | 1 + webrtc/api/BUILD.gn | 12 ++---------- webrtc/api/rtcerror.h | 13 +++++++++++-- webrtc/api/rtcerror_unittest.cc | 16 ++++++++++++---- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index e461af2b3a..8c8cba6c16 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -374,6 +374,7 @@ if (rtc_include_tests) { rtc_test("rtc_unittests") { testonly = true deps = [ + "api:rtc_api_unittests", "base:rtc_base_approved_unittests", "base:rtc_base_unittests", "base:rtc_numerics_unittests", diff --git a/webrtc/api/BUILD.gn b/webrtc/api/BUILD.gn index 5a6051e744..78079b31fa 100644 --- a/webrtc/api/BUILD.gn +++ b/webrtc/api/BUILD.gn @@ -201,9 +201,8 @@ if (rtc_include_tests) { } } - rtc_test("rtc_api_unittests") { + rtc_source_set("rtc_api_unittests") { testonly = true - sources = [ "rtcerror_unittest.cc", ] @@ -215,14 +214,7 @@ if (rtc_include_tests) { deps = [ ":libjingle_peerconnection_api", - "../base:rtc_base_tests_main", - "../base:rtc_base_tests_utils", - "../system_wrappers:metrics_default", - "../test:test_support", + "//webrtc/test:test_support", ] - - if (is_android) { - deps += [ "//testing/android/native_test:native_test_support" ] - } } } diff --git a/webrtc/api/rtcerror.h b/webrtc/api/rtcerror.h index 22714451b5..1c130c0d6e 100644 --- a/webrtc/api/rtcerror.h +++ b/webrtc/api/rtcerror.h @@ -233,8 +233,17 @@ class RTCErrorOr { RTCErrorOr& operator=(const RTCErrorOr& other) = delete; // Move constructor and move-assignment operator. - RTCErrorOr(RTCErrorOr&& other) = default; - RTCErrorOr& operator=(RTCErrorOr&& other) = default; + // + // Visual Studio doesn't support "= default" with move constructors or + // assignment operators (even though they compile, they segfault), so define + // them explicitly. + RTCErrorOr(RTCErrorOr&& other) + : error_(std::move(other.error_)), value_(std::move(other.value_)) {} + RTCErrorOr& operator=(RTCErrorOr&& other) { + error_ = std::move(other.error_); + value_ = std::move(other.value_); + return *this; + } // Conversion constructor and assignment operator; T must be copy or move // constructible from U. diff --git a/webrtc/api/rtcerror_unittest.cc b/webrtc/api/rtcerror_unittest.cc index 32b03add07..486a029fbe 100644 --- a/webrtc/api/rtcerror_unittest.cc +++ b/webrtc/api/rtcerror_unittest.cc @@ -22,8 +22,12 @@ struct MoveOnlyInt { MoveOnlyInt() {} explicit MoveOnlyInt(int value) : value(value) {} MoveOnlyInt(const MoveOnlyInt& other) = delete; - MoveOnlyInt(MoveOnlyInt&& other) = default; - MoveOnlyInt& operator=(MoveOnlyInt&& other) = default; + MoveOnlyInt& operator=(const MoveOnlyInt& other) = delete; + MoveOnlyInt(MoveOnlyInt&& other) : value(other.value) {} + MoveOnlyInt& operator=(MoveOnlyInt&& other) { + value = other.value; + return *this; + } int value = kDefaultMoveOnlyIntValue; }; @@ -34,8 +38,12 @@ struct MoveOnlyInt2 { MoveOnlyInt2() {} explicit MoveOnlyInt2(int value) : value(value) {} MoveOnlyInt2(const MoveOnlyInt2& other) = delete; - MoveOnlyInt2(MoveOnlyInt2&& other) = default; - MoveOnlyInt2& operator=(MoveOnlyInt2&& other) = default; + MoveOnlyInt2& operator=(const MoveOnlyInt2& other) = delete; + MoveOnlyInt2(MoveOnlyInt2&& other) : value(other.value) {} + MoveOnlyInt2& operator=(MoveOnlyInt2&& other) { + value = other.value; + return *this; + } explicit MoveOnlyInt2(MoveOnlyInt&& other) : value(other.value) {} MoveOnlyInt2& operator=(MoveOnlyInt&& other) {