Commit 4c921cc0 authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Platformize Http2MockLog.

Add Http2MockLog and macros in net/third_party/http2/platform.
Remove small divergences from internal code.
Add HpackEntryTypeTest.OutputHpackEntryType test.

This lands server side change 221917881 by bnc.

Bug: 488484

Change-Id: I936519be0dff2bbee4a49f3b0af9e8ee699d2831
Reviewed-on: https://chromium-review.googlesource.com/c/1341199
Commit-Queue: Dianna Hu <diannahu@chromium.org>
Reviewed-by: default avatarDianna Hu <diannahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609920}
parent cfb4a862
...@@ -4994,7 +4994,9 @@ test("net_unittests") { ...@@ -4994,7 +4994,9 @@ test("net_unittests") {
"third_party/http2/http2_structures_test.cc", "third_party/http2/http2_structures_test.cc",
"third_party/http2/http2_structures_test_util.cc", "third_party/http2/http2_structures_test_util.cc",
"third_party/http2/http2_structures_test_util.h", "third_party/http2/http2_structures_test_util.h",
"third_party/http2/platform/api/http2_mock_log.h",
"third_party/http2/platform/api/http2_string_utils_test.cc", "third_party/http2/platform/api/http2_string_utils_test.cc",
"third_party/http2/platform/impl/http2_mock_log_impl.h",
"third_party/http2/test_tools/frame_parts.cc", "third_party/http2/test_tools/frame_parts.cc",
"third_party/http2/test_tools/frame_parts.h", "third_party/http2/test_tools/frame_parts.h",
"third_party/http2/test_tools/frame_parts_collector.cc", "third_party/http2/test_tools/frame_parts_collector.cc",
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "net/third_party/http2/hpack/http2_hpack_constants.h" #include "net/third_party/http2/hpack/http2_hpack_constants.h"
#include <sstream>
#include "net/third_party/http2/platform/api/http2_string_utils.h" #include "net/third_party/http2/platform/api/http2_string_utils.h"
namespace http2 { namespace http2 {
......
...@@ -57,6 +57,7 @@ HTTP2_EXPORT_PRIVATE Http2String HpackEntryTypeToString(HpackEntryType v); ...@@ -57,6 +57,7 @@ HTTP2_EXPORT_PRIVATE Http2String HpackEntryTypeToString(HpackEntryType v);
// Inserts the name of the enum member into |out|. // Inserts the name of the enum member into |out|.
HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out,
HpackEntryType v); HpackEntryType v);
} // namespace http2 } // namespace http2
#endif // NET_THIRD_PARTY_HTTP2_HPACK_HTTP2_HPACK_CONSTANTS_H_ #endif // NET_THIRD_PARTY_HTTP2_HPACK_HTTP2_HPACK_CONSTANTS_H_
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "net/third_party/http2/hpack/http2_hpack_constants.h" #include "net/third_party/http2/hpack/http2_hpack_constants.h"
#include "base/logging.h" #include "base/logging.h"
#include "net/third_party/http2/platform/api/http2_mock_log.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -12,8 +13,6 @@ namespace http2 { ...@@ -12,8 +13,6 @@ namespace http2 {
namespace test { namespace test {
namespace { namespace {
class HpackEntryTypeTest : public testing::Test {};
TEST(HpackEntryTypeTest, HpackEntryTypeToString) { TEST(HpackEntryTypeTest, HpackEntryTypeToString) {
EXPECT_EQ("kIndexedHeader", EXPECT_EQ("kIndexedHeader",
HpackEntryTypeToString(HpackEntryType::kIndexedHeader)); HpackEntryTypeToString(HpackEntryType::kIndexedHeader));
...@@ -29,6 +28,45 @@ TEST(HpackEntryTypeTest, HpackEntryTypeToString) { ...@@ -29,6 +28,45 @@ TEST(HpackEntryTypeTest, HpackEntryTypeToString) {
HpackEntryTypeToString(static_cast<HpackEntryType>(12321))); HpackEntryTypeToString(static_cast<HpackEntryType>(12321)));
} }
TEST(HpackEntryTypeTest, OutputHpackEntryType) {
{
CREATE_HTTP2_MOCK_LOG(log);
log.StartCapturingLogs();
EXPECT_HTTP2_LOG_CALL_CONTAINS(log, INFO, "kIndexedHeader");
LOG(INFO) << HpackEntryType::kIndexedHeader;
}
{
CREATE_HTTP2_MOCK_LOG(log);
log.StartCapturingLogs();
EXPECT_HTTP2_LOG_CALL_CONTAINS(log, INFO, "kDynamicTableSizeUpdate");
LOG(INFO) << HpackEntryType::kDynamicTableSizeUpdate;
}
{
CREATE_HTTP2_MOCK_LOG(log);
log.StartCapturingLogs();
EXPECT_HTTP2_LOG_CALL_CONTAINS(log, INFO, "kIndexedLiteralHeader");
LOG(INFO) << HpackEntryType::kIndexedLiteralHeader;
}
{
CREATE_HTTP2_MOCK_LOG(log);
log.StartCapturingLogs();
EXPECT_HTTP2_LOG_CALL_CONTAINS(log, INFO, "kUnindexedLiteralHeader");
LOG(INFO) << HpackEntryType::kUnindexedLiteralHeader;
}
{
CREATE_HTTP2_MOCK_LOG(log);
log.StartCapturingLogs();
EXPECT_HTTP2_LOG_CALL_CONTAINS(log, INFO, "kNeverIndexedLiteralHeader");
LOG(INFO) << HpackEntryType::kNeverIndexedLiteralHeader;
}
{
CREATE_HTTP2_MOCK_LOG(log);
log.StartCapturingLogs();
EXPECT_HTTP2_LOG_CALL_CONTAINS(log, INFO, "UnknownHpackEntryType(1234321)");
LOG(INFO) << static_cast<HpackEntryType>(1234321);
}
}
} // namespace } // namespace
} // namespace test } // namespace test
} // namespace http2 } // namespace http2
// 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_THIRD_PARTY_HTTP2_PLATFORM_API_HTTP2_MOCK_LOG_H_
#define NET_THIRD_PARTY_HTTP2_PLATFORM_API_HTTP2_MOCK_LOG_H_
#include "net/third_party/http2/platform/impl/http2_mock_log_impl.h"
using Http2MockLog = Http2MockLogImpl;
#define CREATE_HTTP2_MOCK_LOG(log) CREATE_HTTP2_MOCK_LOG_IMPL(log)
#define EXPECT_HTTP2_LOG_CALL(log) EXPECT_HTTP2_LOG_CALL_IMPL(log)
#define EXPECT_HTTP2_LOG_CALL_CONTAINS(log, level, content) \
EXPECT_HTTP2_LOG_CALL_CONTAINS_IMPL(log, level, content)
#endif // NET_THIRD_PARTY_HTTP2_PLATFORM_API_HTTP2_MOCK_LOG_H_
// 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_THIRD_PARTY_HTTP2_PLATFORM_IMPL_HTTP2_MOCK_LOG_IMPL_H_
#define NET_THIRD_PARTY_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_THIRD_PARTY_HTTP2_PLATFORM_IMPL_HTTP2_MOCK_LOG_IMPL_H_
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