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

Unified Diff: net/quic/quic_crypto_stream_test.cc

Issue 11365080: Revert 165858 - Add QuicStream and friends to QUIC code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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/quic_crypto_stream.cc ('k') | net/quic/quic_session.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_crypto_stream_test.cc
===================================================================
--- net/quic/quic_crypto_stream_test.cc (revision 165858)
+++ net/quic/quic_crypto_stream_test.cc (working copy)
@@ -1,100 +0,0 @@
-// Copyright (c) 2012 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/quic_crypto_stream.h"
-
-#include <map>
-#include <string>
-
-#include "net/quic/quic_utils.h"
-#include "net/quic/test_tools/quic_test_utils.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using std::map;
-using std::string;
-
-namespace net {
-namespace test {
-namespace {
-
-class MockQuicCryptoStream : public QuicCryptoStream {
- public:
- explicit MockQuicCryptoStream(QuicSession* session)
- : QuicCryptoStream(session) {
- }
-
- void OnHandshakeMessage(const CryptoHandshakeMessage& message) {
- message_tags_.push_back(message.tag);
- message_maps_.push_back(map<CryptoTag, string>());
- CryptoTagValueMap::const_iterator it = message.tag_value_map.begin();
- while (it != message.tag_value_map.end()) {
- message_maps_.back()[it->first] = it->second.as_string();
- ++it;
- }
- }
-
- std::vector<CryptoTag> message_tags_;
- std::vector<map<CryptoTag, string> > message_maps_;
-};
-
-class QuicCryptoStreamTest : public ::testing::Test {
- public:
- QuicCryptoStreamTest()
- : addr_(IPAddressNumber(), 1),
- connection_(new MockConnection(1, addr_)),
- session_(connection_, true),
- stream_(&session_) {
- message_.tag = kSHLO;
- message_.tag_value_map[1] = "abc";
- message_.tag_value_map[2] = "def";
- ConstructHandshakeMessage();
- }
-
- void ConstructHandshakeMessage() {
- CryptoFramer framer;
- message_data_.reset(framer.ConstructHandshakeMessage(message_));
- }
-
- IPEndPoint addr_;
- MockConnection* connection_;
- MockSession session_;
- MockQuicCryptoStream stream_;
- CryptoHandshakeMessage message_;
- scoped_ptr<QuicData> message_data_;
-};
-
-TEST_F(QuicCryptoStreamTest, NotInitiallyConected) {
- EXPECT_FALSE(stream_.handshake_complete());
-}
-
-TEST_F(QuicCryptoStreamTest, OnErrorClosesConnection) {
- CryptoFramer framer;
- EXPECT_CALL(session_, ConnectionClose(QUIC_NO_ERROR, false));
- stream_.OnError(&framer);
-}
-
-TEST_F(QuicCryptoStreamTest, ProcessData) {
- EXPECT_EQ(message_data_->length(),
- stream_.ProcessData(message_data_->data(),
- message_data_->length()));
- ASSERT_EQ(1u, stream_.message_tags_.size());
- EXPECT_EQ(kSHLO, stream_.message_tags_[0]);
- EXPECT_EQ(2u, stream_.message_maps_[0].size());
- EXPECT_EQ("abc",stream_.message_maps_[0][1]);
- EXPECT_EQ("def", stream_.message_maps_[0][2]);
-}
-
-TEST_F(QuicCryptoStreamTest, ProcessBadData) {
- string bad(message_data_->data(), message_data_->length());
- bad[6] = 0x7F; // out of order tag
-
- EXPECT_CALL(*connection_,
- SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER));
- EXPECT_EQ(0u, stream_.ProcessData(bad.data(), bad.length()));
-}
-
-} // namespace
-} // namespace test
-} // namespace net
« no previous file with comments | « net/quic/quic_crypto_stream.cc ('k') | net/quic/quic_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698