Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/WebKit/public/platform/WebString.h" | 9 #include "third_party/WebKit/public/platform/WebString.h" |
| 10 #include "third_party/WebKit/public/platform/WebURL.h" | 10 #include "third_party/WebKit/public/platform/WebURL.h" |
| 11 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 11 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
| 12 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 12 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 13 #include "webkit/child/multipart_response_delegate.h" | 13 #include "webkit/child/multipart_response_delegate.h" |
| 14 | 14 |
| 15 using std::string; | 15 using std::string; |
| 16 using blink::WebString; | 16 using blink::WebString; |
| 17 using blink::WebURL; | 17 using blink::WebURL; |
| 18 using blink::WebURLError; | 18 using blink::WebURLError; |
| 19 using blink::WebURLLoader; | 19 using blink::WebURLLoader; |
| 20 using blink::WebURLLoaderClient; | 20 using blink::WebURLLoaderClient; |
| 21 using blink::WebURLRequest; | 21 using blink::WebURLRequest; |
| 22 using blink::WebURLResponse; | 22 using blink::WebURLResponse; |
| 23 using content::MultipartResponseDelegateTester; | |
| 23 using webkit_glue::MultipartResponseDelegate; | 24 using webkit_glue::MultipartResponseDelegate; |
| 24 using webkit_glue::MultipartResponseDelegateTester; | |
| 25 | 25 |
| 26 namespace webkit_glue { | 26 namespace content { |
| 27 | 27 |
| 28 class MultipartResponseDelegateTester { | 28 class MultipartResponseDelegateTester { |
| 29 public: | 29 public: |
| 30 MultipartResponseDelegateTester(MultipartResponseDelegate* delegate) | 30 MultipartResponseDelegateTester(MultipartResponseDelegate* delegate) |
| 31 : delegate_(delegate) { | 31 : delegate_(delegate) { |
| 32 } | 32 } |
| 33 | 33 |
| 34 int PushOverLine(const std::string& data, size_t pos) { | 34 int PushOverLine(const std::string& data, size_t pos) { |
| 35 return delegate_->PushOverLine(data, pos); | 35 return delegate_->PushOverLine(data, pos); |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool ParseHeaders() { return delegate_->ParseHeaders(); } | 38 bool ParseHeaders() { return delegate_->ParseHeaders(); } |
| 39 size_t FindBoundary() { return delegate_->FindBoundary(); } | 39 size_t FindBoundary() { return delegate_->FindBoundary(); } |
| 40 std::string& boundary() { return delegate_->boundary_; } | 40 std::string& boundary() { return delegate_->boundary_; } |
| 41 std::string& data() { return delegate_->data_; } | 41 std::string& data() { return delegate_->data_; } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 MultipartResponseDelegate* delegate_; | 44 MultipartResponseDelegate* delegate_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 } // namespace webkit_glue | 47 } // namespace content |
|
jam
2014/05/21 17:00:55
nit: put the entire file in the content namespace,
| |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 class MultipartResponseTest : public testing::Test { | 51 class MultipartResponseTest : public testing::Test { |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 class MockWebURLLoaderClient : public WebURLLoaderClient { | 54 class MockWebURLLoaderClient : public WebURLLoaderClient { |
| 55 public: | 55 public: |
| 56 MockWebURLLoaderClient() { Reset(); } | 56 MockWebURLLoaderClient() { Reset(); } |
| 57 | 57 |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 static_cast<int>(data2.length()), | 667 static_cast<int>(data2.length()), |
| 668 static_cast<int>(data2.length())); | 668 static_cast<int>(data2.length())); |
| 669 EXPECT_EQ(2, client.received_response_); | 669 EXPECT_EQ(2, client.received_response_); |
| 670 EXPECT_EQ(string("response data2"), client.data_); | 670 EXPECT_EQ(string("response data2"), client.data_); |
| 671 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), | 671 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), |
| 672 client.total_encoded_data_length_); | 672 client.total_encoded_data_length_); |
| 673 EXPECT_TRUE(client.response_.isMultipartPayload()); | 673 EXPECT_TRUE(client.response_.isMultipartPayload()); |
| 674 } | 674 } |
| 675 | 675 |
| 676 } // namespace | 676 } // namespace |
| OLD | NEW |