OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/spdy_headers_block_parser.h" | 5 #include "net/spdy/spdy_headers_block_parser.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/sys_byteorder.h" | 11 #include "base/sys_byteorder.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 using base::IntToString; | 17 using base::IntToString; |
18 using base::StringPiece; | 18 using base::StringPiece; |
19 using std::string; | 19 using std::string; |
20 using testing::ElementsAre; | |
21 using testing::ElementsAreArray; | |
22 | 20 |
23 // A mock the handler class to check that we parse out the correct headers | 21 // A mock the handler class to check that we parse out the correct headers |
24 // and call the callback methods when we should. | 22 // and call the callback methods when we should. |
25 class MockSpdyHeadersHandler : public SpdyHeadersHandlerInterface { | 23 class MockSpdyHeadersHandler : public SpdyHeadersHandlerInterface { |
26 public: | 24 public: |
27 MOCK_METHOD2(OnHeaderBlock, void(SpdyStreamId stream_id, | 25 MOCK_METHOD2(OnHeaderBlock, void(SpdyStreamId stream_id, |
28 uint32_t num_of_headers)); | 26 uint32_t num_of_headers)); |
29 MOCK_METHOD2(OnHeaderBlockEnd, void(SpdyStreamId stream_id, size_t bytes)); | 27 MOCK_METHOD2(OnHeaderBlockEnd, void(SpdyStreamId stream_id, size_t bytes)); |
30 MOCK_METHOD3(OnHeader, void(SpdyStreamId stream_id, | 28 MOCK_METHOD3(OnHeader, void(SpdyStreamId stream_id, |
31 StringPiece, | 29 StringPiece, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 string expect_value = kBaseValue + IntToString(0); | 248 string expect_value = kBaseValue + IntToString(0); |
251 EXPECT_CALL(handler_, OnHeader(1, StringPiece(expect_key), | 249 EXPECT_CALL(handler_, OnHeader(1, StringPiece(expect_key), |
252 StringPiece(expect_value))).Times(1); | 250 StringPiece(expect_value))).Times(1); |
253 | 251 |
254 EXPECT_FALSE(parser_-> | 252 EXPECT_FALSE(parser_-> |
255 HandleControlFrameHeadersData(1, headers.c_str(), headers.length())); | 253 HandleControlFrameHeadersData(1, headers.c_str(), headers.length())); |
256 EXPECT_EQ(SpdyHeadersBlockParser::TOO_MUCH_DATA, parser_->get_error()); | 254 EXPECT_EQ(SpdyHeadersBlockParser::TOO_MUCH_DATA, parser_->get_error()); |
257 } | 255 } |
258 | 256 |
259 } // namespace net | 257 } // namespace net |
OLD | NEW |