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

Unified Diff: net/quic/quic_protocol_test.cc

Issue 19858003: * Removed QuicTag kQuicVersion1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compiler errors Created 7 years, 5 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
Index: net/quic/quic_protocol_test.cc
diff --git a/net/quic/quic_protocol_test.cc b/net/quic/quic_protocol_test.cc
index 271cca61e3f7580c961ba599dcbaa4d4716c022e..c46df11fbad3921ed20cc8b232715160d2f0df0c 100644
--- a/net/quic/quic_protocol_test.cc
+++ b/net/quic/quic_protocol_test.cc
@@ -43,6 +43,69 @@ TEST(QuicProtocolTest, InsertMissingPacketsBetween) {
}
}
+TEST(QuicProtocolTest, QuicVersionToQuicTag) {
+ // If you add a new version to the QuicVersion enum you will need to add a new
+ // case to QuicVersionToQuicTag, otherwise this test will fail.
+
+ // Explicitly test a specific version.
+ EXPECT_EQ(MakeQuicTag('Q', '0', '0', '6'),
+ QuicVersionToQuicTag(QUIC_VERSION_6));
+
+ // Loop over all supported versions and make sure that we never hit the
+ // default case (i.e. all supported versions should be successfully converted
+ // to valid QuicTags).
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSupportedQuicVersions); ++i) {
+ const QuicVersion& version = kSupportedQuicVersions[i];
+ EXPECT_LT(0u, QuicVersionToQuicTag(version));
+ }
+}
+
+TEST(QuicProtocolTest, QuicTagToQuicVersion) {
+ // If you add a new version to the QuicVersion enum you will need to add a new
+ // case to QuicTagToQuicVersion, otherwise this test will fail.
+
+ // Explicitly test specific versions.
+ EXPECT_EQ(QUIC_VERSION_6,
+ QuicTagToQuicVersion(MakeQuicTag('Q', '0', '0', '6')));
+ EXPECT_EQ(QUIC_VERSION_UNSUPPORTED,
+ QuicTagToQuicVersion(MakeQuicTag('F', 'A', 'K', 'E')));
+
+ // TODO(rtenneti): Enable checking of Log(ERROR) messages.
+#if 0
ramant (doing other things) 2013/07/23 03:01:30 Hi rch, chromium doesn't have ScopedMockLog. Sho
Ryan Hamilton 2013/07/23 03:40:18 Sounds like a good TODO.
+ // Loop over all supported versions, and make sure we never hit the default
+ // case (which would result in a LOG(ERROR)).
+ ScopedMockLog log(kDoNotCaptureLogsYet);
+ EXPECT_CALL(log, Log(ERROR, _, _)).Times(0);
+ log.StartCapturingLogs();
+#endif
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSupportedQuicVersions); ++i) {
+ const QuicVersion& version = kSupportedQuicVersions[i];
+
+ // Get the tag from the version (we can loop over QuicVersions easily).
+ QuicTag tag = QuicVersionToQuicTag(version);
+ EXPECT_NE(0u, tag);
ramant (doing other things) 2013/07/23 03:01:30 We return 0 when we do LOG(ERROR).
Ryan Hamilton 2013/07/23 03:40:18 Not sure I understand what you mean? Is this code
ramant (doing other things) 2013/07/23 05:05:22 I have add line#87. Everything else is same as goo
+
+ // Now try converting back.
+ EXPECT_EQ(version, QuicTagToQuicVersion(tag));
ramant (doing other things) 2013/07/23 03:01:30 kSupportedQuicVersions shouldn't have QUIC_VERSION
Ryan Hamilton 2013/07/23 03:40:18 Sounds good...
ramant (doing other things) 2013/07/23 05:05:22 Done.
+ }
+}
+
+TEST(QuicProtocolTest, QuicVersionToString) {
+ EXPECT_EQ("QUIC_VERSION_6",
+ QuicVersionToString(QUIC_VERSION_6));
+ EXPECT_EQ("QUIC_VERSION_UNSUPPORTED",
+ QuicVersionToString(QUIC_VERSION_UNSUPPORTED));
+
+ QuicVersion single_version[] = {QUIC_VERSION_6};
+ EXPECT_EQ("QUIC_VERSION_6,", QuicVersionArrayToString(single_version,
+ ARRAYSIZE_UNSAFE(single_version)));
+ // QuicVersion multiple_versions[] = {QUIC_VERSION_7, QUIC_VERSION_6};
+ // EXPECT_EQ("QUIC_VERSION_7,QUIC_VERSION_6,",
+ // QuicVersionArrayToString(multiple_versions,
+ // ARRAYSIZE_UNSAFE(multiple_versions)));
+}
+
} // namespace
} // namespace test
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698