| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/websockets/websocket_inflater.h" | 5 #include "net/websockets/websocket_inflater.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 EXPECT_FALSE(inflater.AddBytes("\xf2\x48\xcd\xc9INVALID DATA", 16)); | 86 EXPECT_FALSE(inflater.AddBytes("\xf2\x48\xcd\xc9INVALID DATA", 16)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 TEST(WebSocketInflaterTest, ChokedInvalidData) { | 89 TEST(WebSocketInflaterTest, ChokedInvalidData) { |
| 90 WebSocketInflater inflater(1, 1); | 90 WebSocketInflater inflater(1, 1); |
| 91 ASSERT_TRUE(inflater.Initialize(15)); | 91 ASSERT_TRUE(inflater.Initialize(15)); |
| 92 | 92 |
| 93 EXPECT_TRUE(inflater.AddBytes("\xf2\x48\xcd\xc9INVALID DATA", 16)); | 93 EXPECT_TRUE(inflater.AddBytes("\xf2\x48\xcd\xc9INVALID DATA", 16)); |
| 94 EXPECT_TRUE(inflater.Finish()); | 94 EXPECT_TRUE(inflater.Finish()); |
| 95 EXPECT_EQ(1u, inflater.CurrentOutputSize()); | 95 EXPECT_EQ(1u, inflater.CurrentOutputSize()); |
| 96 EXPECT_FALSE(inflater.GetOutput(1024)); | 96 EXPECT_FALSE(inflater.GetOutput(1024).get()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 TEST(WebSocketInflaterTest, MultipleAddBytesCalls) { | 99 TEST(WebSocketInflaterTest, MultipleAddBytesCalls) { |
| 100 WebSocketInflater inflater; | 100 WebSocketInflater inflater; |
| 101 ASSERT_TRUE(inflater.Initialize(15)); | 101 ASSERT_TRUE(inflater.Initialize(15)); |
| 102 std::string input("\xf2\x48\xcd\xc9\xc9\x07\x00", 7); | 102 std::string input("\xf2\x48\xcd\xc9\xc9\x07\x00", 7); |
| 103 scoped_refptr<IOBufferWithSize> actual; | 103 scoped_refptr<IOBufferWithSize> actual; |
| 104 | 104 |
| 105 for (size_t i = 0; i < input.size(); ++i) { | 105 for (size_t i = 0; i < input.size(); ++i) { |
| 106 ASSERT_TRUE(inflater.AddBytes(&input[i], 1)); | 106 ASSERT_TRUE(inflater.AddBytes(&input[i], 1)); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 uncompressed->data(), | 215 uncompressed->data(), |
| 216 uncompressed->data() + uncompressed->size()); | 216 uncompressed->data() + uncompressed->size()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 EXPECT_EQ(output, input); | 219 EXPECT_EQ(output, input); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // unnamed namespace | 222 } // unnamed namespace |
| 223 | 223 |
| 224 } // namespace net | 224 } // namespace net |
| OLD | NEW |