Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: net/spdy/spdy_log_util_unittest.cc

Issue 2771033005: Split out spdy_log_util from http_log_util. (Closed)
Patch Set: Remove http_log_util.h include from two files that do not use ElideHeaderValueForNetLog(). Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/spdy_log_util.cc ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_log_util_unittest.cc
diff --git a/net/spdy/spdy_log_util_unittest.cc b/net/spdy/spdy_log_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..40ac1c916efb90ad9e543c68dea1a48f68911319
--- /dev/null
+++ b/net/spdy/spdy_log_util_unittest.cc
@@ -0,0 +1,45 @@
+// 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.
+
+#include "net/spdy/spdy_log_util.h"
+
+#include "base/values.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+TEST(SpdyLogUtilTest, ElideGoAwayDebugDataForNetLog) {
+ // Only elide for appropriate log level.
+ EXPECT_EQ(
+ "[6 bytes were stripped]",
+ ElideGoAwayDebugDataForNetLog(NetLogCaptureMode::Default(), "foobar"));
+ EXPECT_EQ("foobar",
+ ElideGoAwayDebugDataForNetLog(
+ NetLogCaptureMode::IncludeCookiesAndCredentials(), "foobar"));
+}
+
+TEST(SpdyLogUtilTest, ElideSpdyHeaderBlockForNetLog) {
+ SpdyHeaderBlock headers;
+ headers["foo"] = "bar";
+ headers["cookie"] = "name=value";
+
+ std::unique_ptr<base::ListValue> list =
+ ElideSpdyHeaderBlockForNetLog(headers, NetLogCaptureMode::Default());
+ EXPECT_EQ(2u, list->GetSize());
+ std::string field;
+ EXPECT_TRUE(list->GetString(0, &field));
+ EXPECT_EQ("foo: bar", field);
+ EXPECT_TRUE(list->GetString(1, &field));
+ EXPECT_EQ("cookie: [10 bytes were stripped]", field);
+
+ list = ElideSpdyHeaderBlockForNetLog(
+ headers, NetLogCaptureMode::IncludeCookiesAndCredentials());
+ EXPECT_EQ(2u, list->GetSize());
+ EXPECT_TRUE(list->GetString(0, &field));
+ EXPECT_EQ("foo: bar", field);
+ EXPECT_TRUE(list->GetString(1, &field));
+ EXPECT_EQ("cookie: name=value", field);
+}
+
+} // namespace net
« no previous file with comments | « net/spdy/spdy_log_util.cc ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698