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.h" | 10 #include "base/message_loop.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 : message_loop_(base::MessageLoop::TYPE_IO), | 76 : message_loop_(base::MessageLoop::TYPE_IO), |
77 ui_thread_(content::BrowserThread::UI, &message_loop_), | 77 ui_thread_(content::BrowserThread::UI, &message_loop_), |
78 io_thread_(content::BrowserThread::IO, &message_loop_), | 78 io_thread_(content::BrowserThread::IO, &message_loop_), |
79 instant_io_context_(NULL), | 79 instant_io_context_(NULL), |
80 response_(NULL) { | 80 response_(NULL) { |
81 } | 81 } |
82 | 82 |
83 TestIframeSource* source() { return source_.get(); } | 83 TestIframeSource* source() { return source_.get(); } |
84 | 84 |
85 std::string response_string() { | 85 std::string response_string() { |
86 if (response_) { | 86 if (response_.get()) { |
87 return std::string(reinterpret_cast<const char*>(response_->front()), | 87 return std::string(reinterpret_cast<const char*>(response_->front()), |
88 response_->size()); | 88 response_->size()); |
89 } | 89 } |
90 return ""; | 90 return ""; |
91 } | 91 } |
92 | 92 |
93 net::URLRequest* MockRequest( | 93 net::URLRequest* MockRequest( |
94 const std::string& url, | 94 const std::string& url, |
95 bool allocate_info, | 95 bool allocate_info, |
96 int render_process_id, | 96 int render_process_id, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 TEST_F(IframeSourceTest, SendJSWithOrigin) { | 190 TEST_F(IframeSourceTest, SendJSWithOrigin) { |
191 SendJSWithOrigin(IDR_OMNIBOX_RESULT_LOADER_JS, kInstantRendererPID, 0); | 191 SendJSWithOrigin(IDR_OMNIBOX_RESULT_LOADER_JS, kInstantRendererPID, 0); |
192 EXPECT_FALSE(response_string().empty()); | 192 EXPECT_FALSE(response_string().empty()); |
193 EXPECT_NE(std::string::npos, response_string().find(kInstantOrigin)); | 193 EXPECT_NE(std::string::npos, response_string().find(kInstantOrigin)); |
194 SendJSWithOrigin(IDR_OMNIBOX_RESULT_LOADER_JS, kNonInstantRendererPID, 0); | 194 SendJSWithOrigin(IDR_OMNIBOX_RESULT_LOADER_JS, kNonInstantRendererPID, 0); |
195 EXPECT_FALSE(response_string().empty()); | 195 EXPECT_FALSE(response_string().empty()); |
196 EXPECT_NE(std::string::npos, response_string().find(kNonInstantOrigin)); | 196 EXPECT_NE(std::string::npos, response_string().find(kNonInstantOrigin)); |
197 SendJSWithOrigin(IDR_OMNIBOX_RESULT_LOADER_JS, kInvalidRendererPID, 0); | 197 SendJSWithOrigin(IDR_OMNIBOX_RESULT_LOADER_JS, kInvalidRendererPID, 0); |
198 EXPECT_TRUE(response_string().empty()); | 198 EXPECT_TRUE(response_string().empty()); |
199 } | 199 } |
OLD | NEW |