| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fetch/MultipartImageResourceParser.h" | 5 #include "core/fetch/MultipartImageResourceParser.h" |
| 6 | 6 |
| 7 #include "platform/network/ResourceResponse.h" | 7 #include "platform/network/ResourceResponse.h" |
| 8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
| 9 #include "public/platform/WebURL.h" | 9 #include "public/platform/WebURL.h" |
| 10 #include "public/platform/WebURLResponse.h" | 10 #include "public/platform/WebURLResponse.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 #include <stddef.h> | 13 #include <stddef.h> |
| 14 #include <stdint.h> | 14 #include <stdint.h> |
| 15 #include <string.h> | 15 #include <string.h> |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 String toString(const Vector<char>& data) | 21 String toString(const Vector<char>& data) |
| 22 { | 22 { |
| 23 if (data.isEmpty()) | 23 if (data.isEmpty()) |
| 24 return String(""); | 24 return String(""); |
| 25 return String(data.data(), data.size()); | 25 return String(data.data(), data.size()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 class MockClient final : public NoBaseWillBeGarbageCollectedFinalized<MockClient
>, public MultipartImageResourceParser::Client { | 28 class MockClient final : public GarbageCollectedFinalized<MockClient>, public Mu
ltipartImageResourceParser::Client { |
| 29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MockClient); | 29 USING_GARBAGE_COLLECTED_MIXIN(MockClient); |
| 30 | 30 |
| 31 public: | 31 public: |
| 32 void onePartInMultipartReceived(const ResourceResponse& response) override | 32 void onePartInMultipartReceived(const ResourceResponse& response) override |
| 33 { | 33 { |
| 34 m_responses.append(response); | 34 m_responses.append(response); |
| 35 m_data.append(Vector<char>()); | 35 m_data.append(Vector<char>()); |
| 36 } | 36 } |
| 37 void multipartDataReceived(const char* bytes, size_t size) override | 37 void multipartDataReceived(const char* bytes, size_t size) override |
| 38 { | 38 { |
| 39 m_data.last().append(bytes, size); | 39 m_data.last().append(bytes, size); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 EXPECT_EQ("\r\ncontent-type: 1\r\n\r\n\r\n\r\n", toString(client->m_data[1])
); | 498 EXPECT_EQ("\r\ncontent-type: 1\r\n\r\n\r\n\r\n", toString(client->m_data[1])
); |
| 499 EXPECT_EQ(String(), client->m_responses[2].httpHeaderField("content-type")); | 499 EXPECT_EQ(String(), client->m_responses[2].httpHeaderField("content-type")); |
| 500 EXPECT_EQ("content-type: 2\r\n\r\n\r\n\r\n", toString(client->m_data[2])); | 500 EXPECT_EQ("content-type: 2\r\n\r\n\r\n\r\n", toString(client->m_data[2])); |
| 501 EXPECT_EQ("3", client->m_responses[3].httpHeaderField("content-type")); | 501 EXPECT_EQ("3", client->m_responses[3].httpHeaderField("content-type")); |
| 502 EXPECT_EQ("", toString(client->m_data[3])); | 502 EXPECT_EQ("", toString(client->m_data[3])); |
| 503 } | 503 } |
| 504 | 504 |
| 505 } // namespace | 505 } // namespace |
| 506 | 506 |
| 507 } // namespace blink | 507 } // namespace blink |
| OLD | NEW |