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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 void SendJSWithOrigin( | 120 void SendJSWithOrigin( |
121 int resource_id, | 121 int resource_id, |
122 int render_process_id, | 122 int render_process_id, |
123 int render_frame_id) { | 123 int render_frame_id) { |
124 source()->SendJSWithOrigin(resource_id, render_process_id, render_frame_id, | 124 source()->SendJSWithOrigin(resource_id, render_process_id, render_frame_id, |
125 callback_); | 125 callback_); |
126 } | 126 } |
127 | 127 |
128 private: | 128 private: |
129 virtual void SetUp() override { | 129 void SetUp() override { |
130 source_.reset(new TestIframeSource()); | 130 source_.reset(new TestIframeSource()); |
131 callback_ = base::Bind(&IframeSourceTest::SaveResponse, | 131 callback_ = base::Bind(&IframeSourceTest::SaveResponse, |
132 base::Unretained(this)); | 132 base::Unretained(this)); |
133 instant_io_context_ = new InstantIOContext; | 133 instant_io_context_ = new InstantIOContext; |
134 InstantIOContext::SetUserDataOnIO(&resource_context_, instant_io_context_); | 134 InstantIOContext::SetUserDataOnIO(&resource_context_, instant_io_context_); |
135 InstantIOContext::AddInstantProcessOnIO(instant_io_context_, | 135 InstantIOContext::AddInstantProcessOnIO(instant_io_context_, |
136 kInstantRendererPID); | 136 kInstantRendererPID); |
137 response_ = NULL; | 137 response_ = NULL; |
138 } | 138 } |
139 | 139 |
140 virtual void TearDown() { | 140 void TearDown() override { source_.reset(); } |
141 source_.reset(); | |
142 } | |
143 | 141 |
144 void SaveResponse(base::RefCountedMemory* data) { | 142 void SaveResponse(base::RefCountedMemory* data) { |
145 response_ = data; | 143 response_ = data; |
146 } | 144 } |
147 | 145 |
148 content::TestBrowserThreadBundle thread_bundle_; | 146 content::TestBrowserThreadBundle thread_bundle_; |
149 | 147 |
150 net::TestURLRequestContext test_url_request_context_; | 148 net::TestURLRequestContext test_url_request_context_; |
151 content::MockResourceContext resource_context_; | 149 content::MockResourceContext resource_context_; |
152 scoped_ptr<TestIframeSource> source_; | 150 scoped_ptr<TestIframeSource> source_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 190 } |
193 | 191 |
194 TEST_F(IframeSourceTest, SendJSWithOrigin) { | 192 TEST_F(IframeSourceTest, SendJSWithOrigin) { |
195 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInstantRendererPID, 0); | 193 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInstantRendererPID, 0); |
196 EXPECT_FALSE(response_string().empty()); | 194 EXPECT_FALSE(response_string().empty()); |
197 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kNonInstantRendererPID, 0); | 195 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kNonInstantRendererPID, 0); |
198 EXPECT_FALSE(response_string().empty()); | 196 EXPECT_FALSE(response_string().empty()); |
199 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInvalidRendererPID, 0); | 197 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInvalidRendererPID, 0); |
200 EXPECT_TRUE(response_string().empty()); | 198 EXPECT_TRUE(response_string().empty()); |
201 } | 199 } |
OLD | NEW |