Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: content/child/web_url_loader_impl_unittest.cc

Issue 294193002: Set response headers for data URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/child/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/time/time.h"
12 #include "content/child/resource_dispatcher.h" 14 #include "content/child/resource_dispatcher.h"
13 #include "content/public/child/request_peer.h" 15 #include "content/public/child/request_peer.h"
14 #include "content/public/common/resource_response_info.h" 16 #include "content/public/common/resource_response_info.h"
15 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
16 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
17 #include "net/http/http_util.h" 19 #include "net/http/http_util.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/WebKit/public/platform/WebString.h" 21 #include "third_party/WebKit/public/platform/WebString.h"
20 #include "third_party/WebKit/public/platform/WebURLError.h" 22 #include "third_party/WebKit/public/platform/WebURLError.h"
21 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 23 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
(...skipping 23 matching lines...) Expand all
45 // contains multiple chunks, and that it doesn't end with a boundary, so will 47 // contains multiple chunks, and that it doesn't end with a boundary, so will
46 // send data in OnResponseComplete. Also, it will resolve to kTestData. 48 // send data in OnResponseComplete. Also, it will resolve to kTestData.
47 const char kMultipartResponse[] = 49 const char kMultipartResponse[] =
48 "--boundary\n" 50 "--boundary\n"
49 "Content-type: text/html\n\n" 51 "Content-type: text/html\n\n"
50 "bl" 52 "bl"
51 "--boundary\n" 53 "--boundary\n"
52 "Content-type: text/html\n\n" 54 "Content-type: text/html\n\n"
53 "ah!"; 55 "ah!";
54 56
57 TEST(GetInfoFromDataURLTest, Simple) {
darin (slow to review) 2014/08/18 20:23:58 I think the unit testing in src/net/ is sufficient
tyoshino (SeeGerritForStatus) 2014/08/19 13:44:56 OK. Removed.
58 ResourceResponseInfo info;
59 std::string data;
60
61 ASSERT_EQ(net::OK,
62 GetInfoFromDataURL(GURL("data:,Hello"), &info, &data));
63
64 EXPECT_FALSE(info.load_timing.request_start.is_null());
65 EXPECT_FALSE(info.load_timing.request_start_time.is_null());
66 EXPECT_FALSE(info.request_time.is_null());
67 EXPECT_FALSE(info.response_time.is_null());
68 EXPECT_TRUE(info.headers.get());
69 EXPECT_EQ("text/plain", info.mime_type);
70 EXPECT_EQ("US-ASCII", info.charset);
71 EXPECT_TRUE(info.security_info.empty());
72 EXPECT_EQ(5, info.content_length);
73 EXPECT_EQ(0, info.encoded_data_length);
74
75 EXPECT_EQ("Hello", data);
76 }
77
55 class TestBridge : public webkit_glue::ResourceLoaderBridge, 78 class TestBridge : public webkit_glue::ResourceLoaderBridge,
56 public base::SupportsWeakPtr<TestBridge> { 79 public base::SupportsWeakPtr<TestBridge> {
57 public: 80 public:
58 TestBridge() : peer_(NULL), canceled_(false) {} 81 TestBridge() : peer_(NULL), canceled_(false) {}
59 virtual ~TestBridge() {} 82 virtual ~TestBridge() {}
60 83
61 // ResourceLoaderBridge implementation: 84 // ResourceLoaderBridge implementation:
62 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE {} 85 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE {}
63 86
64 virtual bool Start(RequestPeer* peer) OVERRIDE { 87 virtual bool Start(RequestPeer* peer) OVERRIDE {
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 client()->set_delete_on_fail(); 657 client()->set_delete_on_fail();
635 DoStartAsyncRequest(); 658 DoStartAsyncRequest();
636 DoReceiveResponseMultipart(); 659 DoReceiveResponseMultipart();
637 DoReceiveDataMultipart(); 660 DoReceiveDataMultipart();
638 DoFailRequest(); 661 DoFailRequest();
639 EXPECT_FALSE(bridge()); 662 EXPECT_FALSE(bridge());
640 } 663 }
641 664
642 } // namespace 665 } // namespace
643 } // namespace content 666 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698