OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/spdy/core/spdy_test_utils.h" | 5 #include "net/spdy/core/spdy_test_utils.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <memory> | 9 #include <memory> |
10 #include <new> | 10 #include <new> |
(...skipping 20 matching lines...) Expand all Loading... | |
31 static const int kColumns = 4; | 31 static const int kColumns = 4; |
32 | 32 |
33 const int kSizeLimit = 1024; | 33 const int kSizeLimit = 1024; |
34 if (length > kSizeLimit || mark_length > kSizeLimit) { | 34 if (length > kSizeLimit || mark_length > kSizeLimit) { |
35 LOG(ERROR) << "Only dumping first " << kSizeLimit << " bytes."; | 35 LOG(ERROR) << "Only dumping first " << kSizeLimit << " bytes."; |
36 length = std::min(length, kSizeLimit); | 36 length = std::min(length, kSizeLimit); |
37 mark_length = std::min(mark_length, kSizeLimit); | 37 mark_length = std::min(mark_length, kSizeLimit); |
38 } | 38 } |
39 | 39 |
40 SpdyString hex; | 40 SpdyString hex; |
41 for (const unsigned char* row = data; length > 0; | 41 for (const unsigned char *row = data; length > 0; |
42 row += kColumns, length -= kColumns) { | 42 row += kColumns, length -= kColumns) { |
43 for (const unsigned char *p = row; p < row + 4; ++p) { | 43 for (const unsigned char* p = row; p < row + 4; ++p) { |
Biren Roy
2017/05/24 15:25:09
These two diffs, in conjunction, make me sad. :(
Bence
2017/05/24 15:38:48
You are not the only one. I tried to change it, b
| |
44 if (p < row + length) { | 44 if (p < row + length) { |
45 const bool mark = | 45 const bool mark = |
46 (marks && (p - data) < mark_length && marks[p - data]); | 46 (marks && (p - data) < mark_length && marks[p - data]); |
47 hex += mark ? '*' : ' '; | 47 hex += mark ? '*' : ' '; |
48 hex += kHexChars[(*p & 0xf0) >> 4]; | 48 hex += kHexChars[(*p & 0xf0) >> 4]; |
49 hex += kHexChars[*p & 0x0f]; | 49 hex += kHexChars[*p & 0x0f]; |
50 hex += mark ? '*' : ' '; | 50 hex += mark ? '*' : ' '; |
51 } else { | 51 } else { |
52 hex += " "; | 52 hex += " "; |
53 } | 53 } |
(...skipping 22 matching lines...) Expand all Loading... | |
76 if (actual[i] != expected[i]) { | 76 if (actual[i] != expected[i]) { |
77 marks[i] = true; | 77 marks[i] = true; |
78 identical = false; | 78 identical = false; |
79 } else { | 79 } else { |
80 marks[i] = false; | 80 marks[i] = false; |
81 } | 81 } |
82 } | 82 } |
83 for (int i = min_len; i < max_len; ++i) { | 83 for (int i = min_len; i < max_len; ++i) { |
84 marks[i] = true; | 84 marks[i] = true; |
85 } | 85 } |
86 if (identical) return; | 86 if (identical) |
87 ADD_FAILURE() | 87 return; |
88 << "Description:\n" | 88 ADD_FAILURE() << "Description:\n" |
89 << description | 89 << description << "\n\nExpected:\n" |
90 << "\n\nExpected:\n" | 90 << HexDumpWithMarks(expected, expected_len, marks.get(), |
91 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len) | 91 max_len) |
92 << "\nActual:\n" | 92 << "\nActual:\n" |
93 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); | 93 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len); |
94 } | 94 } |
95 | 95 |
96 void SetFrameFlags(SpdySerializedFrame* frame, uint8_t flags) { | 96 void SetFrameFlags(SpdySerializedFrame* frame, uint8_t flags) { |
97 frame->data()[4] = flags; | 97 frame->data()[4] = flags; |
98 } | 98 } |
99 | 99 |
100 void SetFrameLength(SpdySerializedFrame* frame, size_t length) { | 100 void SetFrameLength(SpdySerializedFrame* frame, size_t length) { |
101 CHECK_GT(1u << 14, length); | 101 CHECK_GT(1u << 14, length); |
102 { | 102 { |
103 int32_t wire_length = base::HostToNet32(length); | 103 int32_t wire_length = base::HostToNet32(length); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 bool TestServerPushDelegate::CancelPush(GURL url) { | 172 bool TestServerPushDelegate::CancelPush(GURL url) { |
173 auto itr = push_helpers.find(url); | 173 auto itr = push_helpers.find(url); |
174 DCHECK(itr != push_helpers.end()); | 174 DCHECK(itr != push_helpers.end()); |
175 itr->second->Cancel(); | 175 itr->second->Cancel(); |
176 push_helpers.erase(itr); | 176 push_helpers.erase(itr); |
177 return true; | 177 return true; |
178 } | 178 } |
179 | 179 |
180 } // namespace test | 180 } // namespace test |
181 } // namespace net | 181 } // namespace net |
OLD | NEW |