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 "chrome/browser/search/iframe_source.h" | 5 #include "chrome/browser/search/iframe_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 79 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
80 resource_context_(&test_url_request_context_), | 80 resource_context_(&test_url_request_context_), |
81 instant_io_context_(NULL), | 81 instant_io_context_(NULL), |
82 response_(NULL) { | 82 response_(NULL) { |
83 } | 83 } |
84 | 84 |
85 TestIframeSource* source() { return source_.get(); } | 85 TestIframeSource* source() { return source_.get(); } |
86 | 86 |
87 std::string response_string() { | 87 std::string response_string() { |
88 if (response_.get()) { | 88 if (response_.get()) { |
89 return std::string(reinterpret_cast<const char*>(response_->front()), | 89 return std::string(response_->front_as<char>(), response_->size()); |
90 response_->size()); | |
91 } | 90 } |
92 return ""; | 91 return ""; |
93 } | 92 } |
94 | 93 |
95 net::URLRequest* MockRequest( | 94 net::URLRequest* MockRequest( |
96 const std::string& url, | 95 const std::string& url, |
97 bool allocate_info, | 96 bool allocate_info, |
98 int render_process_id, | 97 int render_process_id, |
99 int render_frame_id) { | 98 int render_frame_id) { |
100 net::URLRequest* request = | 99 net::URLRequest* request = |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 192 } |
194 | 193 |
195 TEST_F(IframeSourceTest, SendJSWithOrigin) { | 194 TEST_F(IframeSourceTest, SendJSWithOrigin) { |
196 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInstantRendererPID, 0); | 195 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInstantRendererPID, 0); |
197 EXPECT_FALSE(response_string().empty()); | 196 EXPECT_FALSE(response_string().empty()); |
198 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kNonInstantRendererPID, 0); | 197 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kNonInstantRendererPID, 0); |
199 EXPECT_FALSE(response_string().empty()); | 198 EXPECT_FALSE(response_string().empty()); |
200 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInvalidRendererPID, 0); | 199 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInvalidRendererPID, 0); |
201 EXPECT_TRUE(response_string().empty()); | 200 EXPECT_TRUE(response_string().empty()); |
202 } | 201 } |
OLD | NEW |