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

Unified Diff: net/quic/core/quic_frames_test.cc

Issue 2537233002: Split out QUIC frame definitions into quic_frames. No behavior change. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/quic/core/quic_frames.cc ('k') | net/quic/core/quic_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_frames_test.cc
diff --git a/net/quic/core/quic_frames_test.cc b/net/quic/core/quic_frames_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c4636c1e20fb9229580e2dbf4b75561e25b49b31
--- /dev/null
+++ b/net/quic/core/quic_frames_test.cc
@@ -0,0 +1,118 @@
+// Copyright (c) 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/quic/core/quic_frames.h"
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace test {
+namespace {
+
+using testing::_;
+
+TEST(QuicProtocolTest, AckFrameToString) {
+ QuicAckFrame frame;
+ frame.largest_observed = 2;
+ frame.ack_delay_time = QuicTime::Delta::FromMicroseconds(3);
+ frame.packets.Add(4);
+ frame.packets.Add(5);
+ frame.received_packet_times = {
+ {6, QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(7)}};
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ(
+ "{ largest_observed: 2, ack_delay_time: 3, "
+ "packets: [ 4 5 ], received_packets: [ 6 at 7 ] }\n",
+ stream.str());
+}
+
+TEST(QuicProtocolTest, PaddingFrameToString) {
+ QuicPaddingFrame frame;
+ frame.num_padding_bytes = 1;
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ("{ num_padding_bytes: 1 }\n", stream.str());
+}
+
+TEST(QuicProtocolTest, RstStreamFrameToString) {
+ QuicRstStreamFrame frame;
+ frame.stream_id = 1;
+ frame.error_code = QUIC_STREAM_CANCELLED;
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ("{ stream_id: 1, error_code: 6 }\n", stream.str());
+}
+
+TEST(QuicProtocolTest, ConnectionCloseFrameToString) {
+ QuicConnectionCloseFrame frame;
+ frame.error_code = QUIC_NETWORK_IDLE_TIMEOUT;
+ frame.error_details = "No recent network activity.";
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ(
+ "{ error_code: 25, error_details: 'No recent network activity.' }\n",
+ stream.str());
+}
+
+TEST(QuicProtocolTest, GoAwayFrameToString) {
+ QuicGoAwayFrame frame;
+ frame.error_code = QUIC_NETWORK_IDLE_TIMEOUT;
+ frame.last_good_stream_id = 2;
+ frame.reason_phrase = "Reason";
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ(
+ "{ error_code: 25, last_good_stream_id: 2, reason_phrase: 'Reason' }\n",
+ stream.str());
+}
+
+TEST(QuicProtocolTest, WindowUpdateFrameToString) {
+ QuicWindowUpdateFrame frame;
+ std::ostringstream stream;
+ frame.stream_id = 1;
+ frame.byte_offset = 2;
+ stream << frame;
+ EXPECT_EQ("{ stream_id: 1, byte_offset: 2 }\n", stream.str());
+}
+
+TEST(QuicProtocolTest, BlockedFrameToString) {
+ QuicBlockedFrame frame;
+ frame.stream_id = 1;
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ("{ stream_id: 1 }\n", stream.str());
+}
+
+TEST(QuicProtocolTest, StreamFrameToString) {
+ QuicStreamFrame frame;
+ frame.stream_id = 1;
+ frame.fin = false;
+ frame.offset = 2;
+ frame.data_length = 3;
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ("{ stream_id: 1, fin: 0, offset: 2, length: 3 }\n", stream.str());
+}
+
+TEST(QuicProtocolTest, StopWaitingFrameToString) {
+ QuicStopWaitingFrame frame;
+ frame.least_unacked = 2;
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ("{ least_unacked: 2 }\n", stream.str());
+}
+
+TEST(QuicProtocolTest, PathCloseFrameToString) {
+ QuicPathCloseFrame frame;
+ frame.path_id = 1;
+ std::ostringstream stream;
+ stream << frame;
+ EXPECT_EQ("{ path_id: 1 }\n", stream.str());
+}
+
+} // namespace
+} // namespace test
+} // namespace net
« no previous file with comments | « net/quic/core/quic_frames.cc ('k') | net/quic/core/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698