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 WebKit::WebString; | 16 using blink::WebString; |
17 using WebKit::WebURL; | 17 using blink::WebURL; |
18 using WebKit::WebURLError; | 18 using blink::WebURLError; |
19 using WebKit::WebURLLoader; | 19 using blink::WebURLLoader; |
20 using WebKit::WebURLLoaderClient; | 20 using blink::WebURLLoaderClient; |
21 using WebKit::WebURLRequest; | 21 using blink::WebURLRequest; |
22 using WebKit::WebURLResponse; | 22 using blink::WebURLResponse; |
23 using webkit_glue::MultipartResponseDelegate; | 23 using webkit_glue::MultipartResponseDelegate; |
24 using webkit_glue::MultipartResponseDelegateTester; | 24 using webkit_glue::MultipartResponseDelegateTester; |
25 | 25 |
26 namespace webkit_glue { | 26 namespace webkit_glue { |
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 } |
(...skipping 27 matching lines...) Expand all Loading... |
60 virtual void didSendData( | 60 virtual void didSendData( |
61 WebURLLoader*, unsigned long long, unsigned long long) {} | 61 WebURLLoader*, unsigned long long, unsigned long long) {} |
62 | 62 |
63 virtual void didReceiveResponse(WebURLLoader* loader, | 63 virtual void didReceiveResponse(WebURLLoader* loader, |
64 const WebURLResponse& response) { | 64 const WebURLResponse& response) { |
65 ++received_response_; | 65 ++received_response_; |
66 response_ = response; | 66 response_ = response; |
67 data_.clear(); | 67 data_.clear(); |
68 } | 68 } |
69 virtual void didReceiveData( | 69 virtual void didReceiveData( |
70 WebKit::WebURLLoader* loader, | 70 blink::WebURLLoader* loader, |
71 const char* data, | 71 const char* data, |
72 int data_length, | 72 int data_length, |
73 int encoded_data_length) { | 73 int encoded_data_length) { |
74 ++received_data_; | 74 ++received_data_; |
75 data_.append(data, data_length); | 75 data_.append(data, data_length); |
76 total_encoded_data_length_ += encoded_data_length; | 76 total_encoded_data_length_ += encoded_data_length; |
77 } | 77 } |
78 virtual void didFinishLoading(WebURLLoader*, double finishTime) {} | 78 virtual void didFinishLoading(WebURLLoader*, double finishTime) {} |
79 virtual void didFail(WebURLLoader*, const WebURLError&) {} | 79 virtual void didFail(WebURLLoader*, const WebURLError&) {} |
80 | 80 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 static_cast<int>(data2.length()), | 666 static_cast<int>(data2.length()), |
667 static_cast<int>(data2.length())); | 667 static_cast<int>(data2.length())); |
668 EXPECT_EQ(2, client.received_response_); | 668 EXPECT_EQ(2, client.received_response_); |
669 EXPECT_EQ(string("response data2"), client.data_); | 669 EXPECT_EQ(string("response data2"), client.data_); |
670 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), | 670 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), |
671 client.total_encoded_data_length_); | 671 client.total_encoded_data_length_); |
672 EXPECT_TRUE(client.response_.isMultipartPayload()); | 672 EXPECT_TRUE(client.response_.isMultipartPayload()); |
673 } | 673 } |
674 | 674 |
675 } // namespace | 675 } // namespace |
OLD | NEW |