Index: net/spdy/spdy_test_utils.cc |
diff --git a/net/spdy/spdy_test_utils.cc b/net/spdy/spdy_test_utils.cc |
deleted file mode 100644 |
index 66806bf8217b00ff953e016f9283ed138d91b962..0000000000000000000000000000000000000000 |
--- a/net/spdy/spdy_test_utils.cc |
+++ /dev/null |
@@ -1,184 +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/spdy/spdy_test_utils.h" |
- |
-#include <algorithm> |
-#include <cstring> |
-#include <memory> |
-#include <utility> |
-#include <vector> |
- |
-#include "base/base64.h" |
-#include "base/logging.h" |
-#include "base/strings/string_number_conversions.h" |
-#include "base/sys_byteorder.h" |
-#include "net/http/transport_security_state.h" |
-#include "net/spdy/spdy_flags.h" |
-#include "net/ssl/ssl_info.h" |
-#include "testing/gtest/include/gtest/gtest.h" |
- |
-namespace net { |
-namespace test { |
- |
-SpdyString HexDumpWithMarks(const unsigned char* data, |
- int length, |
- const bool* marks, |
- int mark_length) { |
- static const char kHexChars[] = "0123456789abcdef"; |
- static const int kColumns = 4; |
- |
- const int kSizeLimit = 1024; |
- if (length > kSizeLimit || mark_length > kSizeLimit) { |
- LOG(ERROR) << "Only dumping first " << kSizeLimit << " bytes."; |
- length = std::min(length, kSizeLimit); |
- mark_length = std::min(mark_length, kSizeLimit); |
- } |
- |
- SpdyString hex; |
- for (const unsigned char* row = data; length > 0; |
- row += kColumns, length -= kColumns) { |
- for (const unsigned char *p = row; p < row + 4; ++p) { |
- if (p < row + length) { |
- const bool mark = |
- (marks && (p - data) < mark_length && marks[p - data]); |
- hex += mark ? '*' : ' '; |
- hex += kHexChars[(*p & 0xf0) >> 4]; |
- hex += kHexChars[*p & 0x0f]; |
- hex += mark ? '*' : ' '; |
- } else { |
- hex += " "; |
- } |
- } |
- hex = hex + " "; |
- |
- for (const unsigned char* p = row; p < row + 4 && p < row + length; ++p) { |
- hex += (*p >= 0x20 && *p <= 0x7f) ? (*p) : '.'; |
- } |
- |
- hex = hex + '\n'; |
- } |
- return hex; |
-} |
- |
-void CompareCharArraysWithHexError(const SpdyString& description, |
- const unsigned char* actual, |
- const int actual_len, |
- const unsigned char* expected, |
- const int expected_len) { |
- const int min_len = std::min(actual_len, expected_len); |
- const int max_len = std::max(actual_len, expected_len); |
- std::unique_ptr<bool[]> marks(new bool[max_len]); |
- bool identical = (actual_len == expected_len); |
- for (int i = 0; i < min_len; ++i) { |
- if (actual[i] != expected[i]) { |
- marks[i] = true; |
- identical = false; |
- } else { |
- marks[i] = false; |
- } |
- } |
- for (int i = min_len; i < max_len; ++i) { |
- marks[i] = true; |
- } |
- if (identical) return; |
- ADD_FAILURE() |
- << "Description:\n" |
- << description |
- << "\n\nExpected:\n" |
- << HexDumpWithMarks(expected, expected_len, marks.get(), max_len) |
- << "\nActual:\n" |
- << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); |
-} |
- |
-void SetFrameFlags(SpdySerializedFrame* frame, uint8_t flags) { |
- frame->data()[4] = flags; |
-} |
- |
-void SetFrameLength(SpdySerializedFrame* frame, size_t length) { |
- CHECK_GT(1u << 14, length); |
- { |
- int32_t wire_length = base::HostToNet32(length); |
- memcpy(frame->data(), reinterpret_cast<char*>(&wire_length) + 1, 3); |
- } |
-} |
- |
-SpdyString a2b_hex(const char* hex_data) { |
- std::vector<uint8_t> output; |
- SpdyString result; |
- if (base::HexStringToBytes(hex_data, &output)) |
- result.assign(reinterpret_cast<const char*>(&output[0]), output.size()); |
- return result; |
-} |
- |
-HashValue GetTestHashValue(uint8_t label) { |
- HashValue hash_value(HASH_VALUE_SHA256); |
- memset(hash_value.data(), label, hash_value.size()); |
- return hash_value; |
-} |
- |
-SpdyString GetTestPin(uint8_t label) { |
- HashValue hash_value = GetTestHashValue(label); |
- SpdyString base64; |
- base::Base64Encode(SpdyStringPiece(reinterpret_cast<char*>(hash_value.data()), |
- hash_value.size()), |
- &base64); |
- |
- return SpdyString("pin-sha256=\"") + base64 + "\""; |
-} |
- |
-void AddPin(TransportSecurityState* state, |
- const SpdyString& host, |
- uint8_t primary_label, |
- uint8_t backup_label) { |
- SpdyString primary_pin = GetTestPin(primary_label); |
- SpdyString backup_pin = GetTestPin(backup_label); |
- SpdyString header = "max-age = 10000; " + primary_pin + "; " + backup_pin; |
- |
- // Construct a fake SSLInfo that will pass AddHPKPHeader's checks. |
- SSLInfo ssl_info; |
- ssl_info.is_issued_by_known_root = true; |
- ssl_info.public_key_hashes.push_back(GetTestHashValue(primary_label)); |
- EXPECT_TRUE(state->AddHPKPHeader(host, header, ssl_info)); |
-} |
- |
-void TestHeadersHandler::OnHeaderBlockStart() { |
- block_.clear(); |
-} |
- |
-void TestHeadersHandler::OnHeader(SpdyStringPiece name, SpdyStringPiece value) { |
- block_.AppendValueOrAddHeader(name, value); |
-} |
- |
-void TestHeadersHandler::OnHeaderBlockEnd(size_t header_bytes_parsed) { |
- OnHeaderBlockEnd(header_bytes_parsed, 0); |
-} |
- |
-void TestHeadersHandler::OnHeaderBlockEnd( |
- size_t header_bytes_parsed, |
- size_t compressed_header_bytes_parsed) { |
- header_bytes_parsed_ = header_bytes_parsed; |
- compressed_header_bytes_parsed_ = compressed_header_bytes_parsed; |
-} |
- |
-TestServerPushDelegate::TestServerPushDelegate() {} |
- |
-TestServerPushDelegate::~TestServerPushDelegate() {} |
- |
-void TestServerPushDelegate::OnPush( |
- std::unique_ptr<ServerPushHelper> push_helper, |
- const NetLogWithSource& session_net_log) { |
- push_helpers[push_helper->GetURL()] = std::move(push_helper); |
-} |
- |
-bool TestServerPushDelegate::CancelPush(GURL url) { |
- auto itr = push_helpers.find(url); |
- DCHECK(itr != push_helpers.end()); |
- itr->second->Cancel(); |
- push_helpers.erase(itr); |
- return true; |
-} |
- |
-} // namespace test |
-} // namespace net |