summaryrefslogtreecommitdiff
path: root/chromium/net/http2
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 16:23:34 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-14 10:37:21 +0000
commit38a9a29f4f9436cace7f0e7abf9c586057df8a4e (patch)
treec4e8c458dc595bc0ddb435708fa2229edfd00bd4 /chromium/net/http2
parente684a3455bcc29a6e3e66a004e352dea4e1141e7 (diff)
downloadqtwebengine-chromium-38a9a29f4f9436cace7f0e7abf9c586057df8a4e.tar.gz
BASELINE: Update Chromium to 73.0.3683.37
Change-Id: I08c9af2948b645f671e5d933aca1f7a90ea372f2 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/net/http2')
-rw-r--r--chromium/net/http2/platform/impl/http2_arraysize_impl.h12
-rw-r--r--chromium/net/http2/platform/impl/http2_bug_tracker_impl.h14
-rw-r--r--chromium/net/http2/platform/impl/http2_containers_impl.h17
-rw-r--r--chromium/net/http2/platform/impl/http2_estimate_memory_usage_impl.h21
-rw-r--r--chromium/net/http2/platform/impl/http2_export_impl.h13
-rw-r--r--chromium/net/http2/platform/impl/http2_flag_utils_impl.h13
-rw-r--r--chromium/net/http2/platform/impl/http2_flags_impl.cc7
-rw-r--r--chromium/net/http2/platform/impl/http2_flags_impl.h31
-rw-r--r--chromium/net/http2/platform/impl/http2_macros_impl.h15
-rw-r--r--chromium/net/http2/platform/impl/http2_mock_log_impl.h22
-rw-r--r--chromium/net/http2/platform/impl/http2_optional_impl.h17
-rw-r--r--chromium/net/http2/platform/impl/http2_ptr_util_impl.h20
-rw-r--r--chromium/net/http2/platform/impl/http2_reconstruct_object_impl.h34
-rw-r--r--chromium/net/http2/platform/impl/http2_string_impl.h16
-rw-r--r--chromium/net/http2/platform/impl/http2_string_piece_impl.h16
-rw-r--r--chromium/net/http2/platform/impl/http2_string_utils_impl.h65
-rw-r--r--chromium/net/http2/platform/impl/http2_test_helpers_impl.cc29
-rw-r--r--chromium/net/http2/platform/impl/http2_test_helpers_impl.h167
18 files changed, 529 insertions, 0 deletions
diff --git a/chromium/net/http2/platform/impl/http2_arraysize_impl.h b/chromium/net/http2/platform/impl/http2_arraysize_impl.h
new file mode 100644
index 00000000000..5a927234307
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_arraysize_impl.h
@@ -0,0 +1,12 @@
+// Copyright 2018 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_ARRAYSIZE_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_ARRAYSIZE_IMPL_H_
+
+#include "base/stl_util.h"
+
+#define HTTP2_ARRAYSIZE_IMPL(x) base::size(x)
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_ARRAYSIZE_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_bug_tracker_impl.h b/chromium/net/http2/platform/impl/http2_bug_tracker_impl.h
new file mode 100644
index 00000000000..8ee3bd02460
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_bug_tracker_impl.h
@@ -0,0 +1,14 @@
+// Copyright 2016 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_BUG_TRACKER_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_BUG_TRACKER_IMPL_H_
+
+#include "base/logging.h"
+
+#define HTTP2_BUG_IMPL LOG(DFATAL)
+#define HTTP2_BUG_IF_IMPL LOG_IF(DFATAL, (condition))
+#define FLAGS_http2_always_log_bugs_for_tests_IMPL (true)
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_BUG_TRACKER_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_containers_impl.h b/chromium/net/http2/platform/impl/http2_containers_impl.h
new file mode 100644
index 00000000000..51044a5e76c
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_containers_impl.h
@@ -0,0 +1,17 @@
+// Copyright (c) 2018 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_CONTAINERS_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_CONTAINERS_IMPL_H_
+
+#include "base/containers/circular_deque.h"
+
+namespace http2 {
+
+template <typename T>
+using Http2DequeImpl = base::circular_deque<T>;
+
+}
+
+#endif /* NET_HTTP2_PLATFORM_IMPL_HTTP2_CONTAINERS_IMPL_H_ */
diff --git a/chromium/net/http2/platform/impl/http2_estimate_memory_usage_impl.h b/chromium/net/http2/platform/impl/http2_estimate_memory_usage_impl.h
new file mode 100644
index 00000000000..4581adc1ee6
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_estimate_memory_usage_impl.h
@@ -0,0 +1,21 @@
+// Copyright 2017 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_ESTIMATE_MEMORY_USAGE_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_ESTIMATE_MEMORY_USAGE_IMPL_H_
+
+#include <cstddef>
+
+#include "base/trace_event/memory_usage_estimator.h"
+
+namespace http2 {
+
+template <class T>
+size_t Http2EstimateMemoryUsageImpl(const T& object) {
+ return base::trace_event::EstimateMemoryUsage(object);
+}
+
+} // namespace http2
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_ESTIMATE_MEMORY_USAGE_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_export_impl.h b/chromium/net/http2/platform/impl/http2_export_impl.h
new file mode 100644
index 00000000000..f2321c64de8
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_export_impl.h
@@ -0,0 +1,13 @@
+// Copyright 2017 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_EXPORT_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_EXPORT_IMPL_H_
+
+#include "net/base/net_export.h"
+
+#define HTTP2_EXPORT NET_EXPORT
+#define HTTP2_EXPORT_PRIVATE NET_EXPORT_PRIVATE
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_EXPORT_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_flag_utils_impl.h b/chromium/net/http2/platform/impl/http2_flag_utils_impl.h
new file mode 100644
index 00000000000..73b87188ceb
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_flag_utils_impl.h
@@ -0,0 +1,13 @@
+// Copyright 2018 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_FLAG_UTILS_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_FLAG_UTILS_IMPL_H_
+
+#include "base/logging.h"
+
+#define HTTP2_RELOADABLE_FLAG_COUNT_IMPL(flag) \
+ DVLOG(1) << "FLAG_" #flag ": " << FLAGS_##flag
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_FLAG_UTILS_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_flags_impl.cc b/chromium/net/http2/platform/impl/http2_flags_impl.cc
new file mode 100644
index 00000000000..21704559544
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_flags_impl.cc
@@ -0,0 +1,7 @@
+// Copyright 2018 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 "net/http2/platform/impl/http2_flags_impl.h"
+
+bool FLAGS_http2_varint_decode_64_bits = true;
diff --git a/chromium/net/http2/platform/impl/http2_flags_impl.h b/chromium/net/http2/platform/impl/http2_flags_impl.h
new file mode 100644
index 00000000000..e9dbdc079da
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_flags_impl.h
@@ -0,0 +1,31 @@
+// Copyright 2018 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_FLAGS_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_FLAGS_IMPL_H_
+
+#include "net/third_party/quiche/src/http2/platform/api/http2_export.h"
+
+HTTP2_EXPORT_PRIVATE extern bool FLAGS_http2_varint_decode_64_bits;
+
+namespace http2 {
+
+inline bool GetHttp2FlagImpl(bool flag) {
+ return flag;
+}
+
+inline void SetHttp2FlagImpl(bool* f, bool v) {
+ *f = v;
+}
+
+#define HTTP2_RELOADABLE_FLAG(flag) FLAGS_##flag
+
+#define GetHttp2ReloadableFlagImpl(flag) \
+ GetHttp2FlagImpl(HTTP2_RELOADABLE_FLAG(flag))
+#define SetHttp2ReloadableFlagImpl(flag, value) \
+ SetHttp2FlagImpl(&HTTP2_RELOADABLE_FLAG(flag), value)
+
+} // namespace http2
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_FLAGS_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_macros_impl.h b/chromium/net/http2/platform/impl/http2_macros_impl.h
new file mode 100644
index 00000000000..17628d338f3
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_macros_impl.h
@@ -0,0 +1,15 @@
+// Copyright (c) 2018 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_MACROS_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_MACROS_IMPL_H_
+
+#include "base/compiler_specific.h"
+#include "base/logging.h"
+
+#define HTTP2_FALLTHROUGH_IMPL FALLTHROUGH
+#define HTTP2_UNREACHABLE_IMPL() DCHECK(false)
+#define HTTP2_DIE_IF_NULL_IMPL(ptr) (ptr)
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_MACROS_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_mock_log_impl.h b/chromium/net/http2/platform/impl/http2_mock_log_impl.h
new file mode 100644
index 00000000000..254f56d0166
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_mock_log_impl.h
@@ -0,0 +1,22 @@
+// Copyright 2018 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_MOCK_LOG_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_MOCK_LOG_IMPL_H_
+
+#include "base/test/mock_log.h"
+#include "testing/gmock/include/gmock/gmock.h" // IWYU pragma: export
+
+using Http2MockLogImpl = base::test::MockLog;
+#define CREATE_HTTP2_MOCK_LOG_IMPL(log) Http2MockLog log
+
+#define EXPECT_HTTP2_LOG_CALL_IMPL(log) \
+ EXPECT_CALL(log, \
+ Log(testing::_, testing::_, testing::_, testing::_, testing::_))
+
+#define EXPECT_HTTP2_LOG_CALL_CONTAINS_IMPL(log, level, content) \
+ EXPECT_CALL(log, Log(logging::LOG_##level, testing::_, testing::_, \
+ testing::_, testing::HasSubstr(content)))
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_MOCK_LOG_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_optional_impl.h b/chromium/net/http2/platform/impl/http2_optional_impl.h
new file mode 100644
index 00000000000..f6d570307c1
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_optional_impl.h
@@ -0,0 +1,17 @@
+// Copyright 2018 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_OPTIONAL_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_OPTIONAL_IMPL_H_
+
+#include "base/optional.h"
+
+namespace http2 {
+
+template <typename T>
+using Http2OptionalImpl = base::Optional<T>;
+
+} // namespace http2
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_OPTIONAL_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_ptr_util_impl.h b/chromium/net/http2/platform/impl/http2_ptr_util_impl.h
new file mode 100644
index 00000000000..af84848b11f
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_ptr_util_impl.h
@@ -0,0 +1,20 @@
+// Copyright 2018 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_PTR_UTIL_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_PTR_UTIL_IMPL_H_
+
+#include <memory>
+#include <utility>
+
+namespace http2 {
+
+template <typename T, typename... Args>
+std::unique_ptr<T> Http2MakeUniqueImpl(Args&&... args) {
+ return std::make_unique<T>(std::forward<Args>(args)...);
+}
+
+} // namespace http2
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_PTR_UTIL_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_reconstruct_object_impl.h b/chromium/net/http2/platform/impl/http2_reconstruct_object_impl.h
new file mode 100644
index 00000000000..4f4588fe1d0
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_reconstruct_object_impl.h
@@ -0,0 +1,34 @@
+// Copyright 2017 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_RECONSTRUCT_OBJECT_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_RECONSTRUCT_OBJECT_IMPL_H_
+
+#include <utility>
+
+namespace http2 {
+namespace test {
+
+class Http2Random;
+
+// Reconstruct an object so that it is initialized as when it was first
+// constructed. Runs the destructor to handle objects that might own resources,
+// and runs the constructor with the provided arguments, if any.
+template <class T, class... Args>
+void Http2ReconstructObjectImpl(T* ptr, Http2Random* rng, Args&&... args) {
+ ptr->~T();
+ ::new (ptr) T(std::forward<Args>(args)...);
+}
+
+// This version applies default-initialization to the object.
+template <class T>
+void Http2DefaultReconstructObjectImpl(T* ptr, Http2Random* rng) {
+ ptr->~T();
+ ::new (ptr) T;
+}
+
+} // namespace test
+} // namespace http2
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_RECONSTRUCT_OBJECT_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_string_impl.h b/chromium/net/http2/platform/impl/http2_string_impl.h
new file mode 100644
index 00000000000..1379674cc6a
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_string_impl.h
@@ -0,0 +1,16 @@
+// Copyright (c) 2017 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_IMPL_H_
+
+#include <string>
+
+namespace http2 {
+
+using Http2StringImpl = std::string;
+
+} // namespace http2
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_string_piece_impl.h b/chromium/net/http2/platform/impl/http2_string_piece_impl.h
new file mode 100644
index 00000000000..b952c5edaf5
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_string_piece_impl.h
@@ -0,0 +1,16 @@
+// Copyright (c) 2017 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_PIECE_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_PIECE_IMPL_H_
+
+#include "base/strings/string_piece.h"
+
+namespace http2 {
+
+using Http2StringPieceImpl = base::StringPiece;
+
+} // namespace http2
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_PIECE_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_string_utils_impl.h b/chromium/net/http2/platform/impl/http2_string_utils_impl.h
new file mode 100644
index 00000000000..5b648b0601e
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_string_utils_impl.h
@@ -0,0 +1,65 @@
+// Copyright 2017 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_UTILS_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_UTILS_IMPL_H_
+
+#include <sstream>
+#include <utility>
+
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "net/base/escape.h"
+#include "net/base/hex_utils.h"
+#include "net/third_party/quiche/src/http2/platform/api/http2_export.h"
+#include "net/third_party/quiche/src/http2/platform/api/http2_string.h"
+#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h"
+
+namespace http2 {
+
+template <typename... Args>
+inline Http2String Http2StrCatImpl(const Args&... args) {
+ std::ostringstream oss;
+ int dummy[] = {1, (oss << args, 0)...};
+ static_cast<void>(dummy);
+ return oss.str();
+}
+
+template <typename... Args>
+inline void Http2StrAppendImpl(Http2String* output, Args... args) {
+ output->append(Http2StrCatImpl(args...));
+}
+
+template <typename... Args>
+inline Http2String Http2StringPrintfImpl(const Args&... args) {
+ return base::StringPrintf(std::forward<const Args&>(args)...);
+}
+
+inline Http2String Http2HexEncodeImpl(const void* bytes, size_t size) {
+ return base::HexEncode(bytes, size);
+}
+
+inline Http2String Http2HexDecodeImpl(Http2StringPiece data) {
+ return net::HexDecode(data);
+}
+
+inline Http2String Http2HexDumpImpl(Http2StringPiece data) {
+ return net::HexDump(data);
+}
+
+inline Http2String Http2HexEscapeImpl(Http2StringPiece data) {
+ return net::EscapeQueryParamValue(data, false);
+}
+
+template <typename Number>
+inline Http2String Http2HexImpl(Number number) {
+ std::stringstream str;
+ str << std::hex << number;
+ return str.str();
+}
+
+} // namespace http2
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_STRING_UTILS_IMPL_H_
diff --git a/chromium/net/http2/platform/impl/http2_test_helpers_impl.cc b/chromium/net/http2/platform/impl/http2_test_helpers_impl.cc
new file mode 100644
index 00000000000..a00de1e0402
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_test_helpers_impl.cc
@@ -0,0 +1,29 @@
+// Copyright 2016 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 "net/third_party/quiche/src/http2/platform/api/http2_test_helpers.h"
+
+namespace http2 {
+namespace test {
+
+// This is a copy of the same named method in ::testing::internal.
+// TODO(jamessynge): See about getting something like VERIFY_* adopted by
+// gUnit (probably a very difficult task!).
+Http2String GetBoolAssertionFailureMessage(
+ const ::testing::AssertionResult& assertion_result,
+ const char* expression_text,
+ const char* actual_predicate_value,
+ const char* expected_predicate_value) {
+ const char* actual_message = assertion_result.message();
+ ::testing::Message msg;
+ msg << "Value of: " << expression_text
+ << "\n Actual: " << actual_predicate_value;
+ if (actual_message[0] != '\0')
+ msg << " (" << actual_message << ")";
+ msg << "\nExpected: " << expected_predicate_value;
+ return msg.GetString();
+}
+
+} // namespace test
+} // namespace http2
diff --git a/chromium/net/http2/platform/impl/http2_test_helpers_impl.h b/chromium/net/http2/platform/impl/http2_test_helpers_impl.h
new file mode 100644
index 00000000000..535b2171173
--- /dev/null
+++ b/chromium/net/http2/platform/impl/http2_test_helpers_impl.h
@@ -0,0 +1,167 @@
+// Copyright 2016 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 NET_HTTP2_PLATFORM_IMPL_HTTP2_TEST_HELPERS_IMPL_H_
+#define NET_HTTP2_PLATFORM_IMPL_HTTP2_TEST_HELPERS_IMPL_H_
+
+// Defines VERIFY_* macros, analogous to gUnit's EXPECT_* and ASSERT_* macros,
+// but these return an appropriate AssertionResult if the condition is not
+// satisfied. This enables one to create a function for verifying expectations
+// that are needed by multiple callers or that rely on arguments not accessible
+// to the main test method. Using VERIFY_SUCCESS allows one to annotate the
+// a failing AssertionResult with more context.
+
+#include <iosfwd>
+#include <sstream>
+
+#include "net/test/gtest_util.h"
+#include "net/third_party/quiche/src/http2/platform/api/http2_string.h"
+#include "testing/gmock/include/gmock/gmock-matchers.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace http2 {
+namespace test {
+
+template <typename T>
+class VerifyThatHelper {
+ public:
+ VerifyThatHelper(const T& value, ::testing::Matcher<T> matcher) {
+ matches_ = matcher.Matches(value);
+ if (!matches_) {
+ printed_value_ = ::testing::PrintToString(value);
+
+ std::ostringstream os;
+ matcher.DescribeTo(&os);
+ matcher_description_ = os.str();
+ }
+ }
+
+ VerifyThatHelper(const VerifyThatHelper&) = delete;
+ VerifyThatHelper& operator=(const VerifyThatHelper&) = delete;
+
+ operator bool() const { return matches_; }
+
+ const Http2String& printed_value() const { return printed_value_; }
+ const Http2String& matcher_description() const {
+ return matcher_description_;
+ }
+
+ private:
+ bool matches_;
+ Http2String printed_value_;
+ Http2String matcher_description_;
+};
+
+// Constructs a failure message for Boolean assertions such as VERIFY_TRUE.
+Http2String GetBoolAssertionFailureMessage(
+ const ::testing::AssertionResult& assertion_result,
+ const char* expression_text,
+ const char* actual_predicate_value,
+ const char* expected_predicate_value);
+
+namespace {
+// Define HasSubstr() for Http2StringPiece arguments.
+// This shadows ::testing::HasSubstr(), which only works on argument types
+// that can be implicitly converted to a Http2String.
+inline ::testing::PolymorphicMatcher<net::test::StringPieceHasSubstrMatcher>
+HasSubstr(const Http2String& substring) {
+ return ::testing::MakePolymorphicMatcher(
+ net::test::StringPieceHasSubstrMatcher(substring));
+}
+} // namespace
+
+} // namespace test
+} // namespace http2
+
+// Macro for adding verification location to output stream or AssertionResult.
+// Starts with a new-line because of the way that gUnit displays failures for
+// EXPECT_TRUE(CallToFunctionThatFailsToVerify()).
+#define VERIFY_FAILED_LOCATION_ \
+ "\n" \
+ << "(VERIFY failed in " << __func__ << "\n" \
+ << " at " __FILE__ " : " << __LINE__ << ")\n"
+
+// Implements Boolean test verifications VERIFY_TRUE and VERIFY_FALSE.
+// text is a textual represenation of expression as it was passed into
+// VERIFY_TRUE or VERIFY_FALSE.
+// clang-format off
+#define VERIFY_TEST_BOOLEAN_(condition, text, actual, expected) \
+ if (const ::testing::AssertionResult __assertion_result = \
+ ::testing::AssertionResult((condition) ? expected : actual)) \
+ ; \
+ else \
+ return ::testing::AssertionFailure() \
+ << VERIFY_FAILED_LOCATION_ \
+ << ::http2::test::GetBoolAssertionFailureMessage( \
+ __assertion_result, text, #actual, #expected)
+// clang-format on
+
+// Boolean assertions. condition can be either a Boolean expression or an
+// expression convertable to a boolean (such as a ::gtl::labs::optional).
+#define VERIFY_TRUE(condition) \
+ VERIFY_TEST_BOOLEAN_(condition, #condition, false, true)
+
+#define VERIFY_FALSE(condition) \
+ VERIFY_TEST_BOOLEAN_(condition, #condition, true, false)
+
+// Convenient helper macro for writing methods that return an AssertionFailure
+// that includes the tested condition in the message (in the manner of
+// ASSERT_THAT and EXPECT_THAT).
+//
+// This macro avoids the do {} while(false) trick and putting braces around
+// the if so you can do things like:
+// VERIFY_THAT(foo, Lt(4)) << "foo too big in iteration " << i;
+// (This parallels the implementation of CHECK().)
+//
+// We use an if statement with an empty true branch so that this doesn't eat
+// a neighboring else when used in an unbraced if statement like:
+// if (condition)
+// VERIFY_THAT(foo, Eq(bar));
+// else
+// FAIL();
+#define VERIFY_THAT(value, matcher) \
+ if (const auto& _verify_that_helper = \
+ ::http2::test::VerifyThatHelper<decltype(value)>(value, matcher)) \
+ ; \
+ else \
+ return ::testing::AssertionFailure() \
+ << "Failed to verify that '" #value "' (" \
+ << _verify_that_helper.printed_value() << ") " \
+ << _verify_that_helper.matcher_description() \
+ << " (on " __FILE__ ":" << __LINE__ << "). "
+
+// Useful variants of VERIFY_THAT, similar to the corresponding EXPECT_X or
+// ASSERT_X defined by gUnit.
+#define VERIFY_EQ(val1, val2) VERIFY_THAT(val1, ::testing::Eq(val2))
+#define VERIFY_NE(val1, val2) VERIFY_THAT(val1, ::testing::Ne(val2))
+#define VERIFY_GT(val1, val2) VERIFY_THAT(val1, ::testing::Gt(val2))
+#define VERIFY_LT(val1, val2) VERIFY_THAT(val1, ::testing::Lt(val2))
+#define VERIFY_GE(val1, val2) VERIFY_THAT(val1, ::testing::Ge(val2))
+#define VERIFY_LE(val1, val2) VERIFY_THAT(val1, ::testing::Le(val2))
+
+// Convenience macro matching EXPECT_OK
+#define VERIFY_OK(statement) VERIFY_EQ(::util::Status::OK, (statement))
+
+// This version verifies that an expression of type AssertionResult is
+// AssertionSuccess. If instead the value is an AssertionFailure, it appends
+// info about the current code location to the failure's message and returns
+// the failure to the caller of the current method. It permits the code site
+// to append further messages to the failure message. For example:
+// VERIFY_SUCCESS(SomeCall()) << "Some more context about SomeCall";
+// clang-format off
+#define VERIFY_SUCCESS(expr) \
+ if (::testing::AssertionResult __assertion_result = (expr)) \
+ ; \
+ else \
+ return __assertion_result << VERIFY_FAILED_LOCATION_
+// clang-format on
+
+#define VERIFY_AND_RETURN_SUCCESS(expression) \
+ { \
+ VERIFY_SUCCESS(expression); \
+ return ::testing::AssertionSuccess(); \
+ }
+
+#endif // NET_HTTP2_PLATFORM_IMPL_HTTP2_TEST_HELPERS_IMPL_H_