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_pinnable_buffer_piece.h" | 5 #include "net/spdy/spdy_pinnable_buffer_piece.h" |
6 | 6 |
| 7 #include "net/spdy/platform/api/spdy_string.h" |
7 #include "net/spdy/spdy_prefixed_buffer_reader.h" | 8 #include "net/spdy/spdy_prefixed_buffer_reader.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 namespace net { | 11 namespace net { |
11 | 12 |
12 namespace test { | 13 namespace test { |
13 | 14 |
14 class SpdyPinnableBufferPieceTest : public ::testing::Test { | 15 class SpdyPinnableBufferPieceTest : public ::testing::Test { |
15 protected: | 16 protected: |
16 SpdyPrefixedBufferReader Build(const std::string& prefix, | 17 SpdyPrefixedBufferReader Build(const SpdyString& prefix, |
17 const std::string& suffix) { | 18 const SpdyString& suffix) { |
18 prefix_ = prefix; | 19 prefix_ = prefix; |
19 suffix_ = suffix; | 20 suffix_ = suffix; |
20 return SpdyPrefixedBufferReader(prefix_.data(), prefix_.length(), | 21 return SpdyPrefixedBufferReader(prefix_.data(), prefix_.length(), |
21 suffix_.data(), suffix_.length()); | 22 suffix_.data(), suffix_.length()); |
22 } | 23 } |
23 std::string prefix_, suffix_; | 24 SpdyString prefix_, suffix_; |
24 }; | 25 }; |
25 | 26 |
26 TEST_F(SpdyPinnableBufferPieceTest, Pin) { | 27 TEST_F(SpdyPinnableBufferPieceTest, Pin) { |
27 SpdyPrefixedBufferReader reader = Build("foobar", ""); | 28 SpdyPrefixedBufferReader reader = Build("foobar", ""); |
28 SpdyPinnableBufferPiece piece; | 29 SpdyPinnableBufferPiece piece; |
29 EXPECT_TRUE(reader.ReadN(6, &piece)); | 30 EXPECT_TRUE(reader.ReadN(6, &piece)); |
30 | 31 |
31 // Piece points to underlying prefix storage. | 32 // Piece points to underlying prefix storage. |
32 EXPECT_EQ(SpdyStringPiece("foobar"), SpdyStringPiece(piece)); | 33 EXPECT_EQ(SpdyStringPiece("foobar"), SpdyStringPiece(piece)); |
33 EXPECT_FALSE(piece.IsPinned()); | 34 EXPECT_FALSE(piece.IsPinned()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 SpdyPinnableBufferPiece empty; | 70 SpdyPinnableBufferPiece empty; |
70 piece2.Swap(&empty); | 71 piece2.Swap(&empty); |
71 | 72 |
72 EXPECT_EQ(SpdyStringPiece(""), SpdyStringPiece(piece2)); | 73 EXPECT_EQ(SpdyStringPiece(""), SpdyStringPiece(piece2)); |
73 EXPECT_FALSE(piece2.IsPinned()); | 74 EXPECT_FALSE(piece2.IsPinned()); |
74 } | 75 } |
75 | 76 |
76 } // namespace test | 77 } // namespace test |
77 | 78 |
78 } // namespace net | 79 } // namespace net |
OLD | NEW |