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

Side by Side Diff: chrome_frame/test/urlmon_moniker_integration_test.cc

Issue 6825055: Include base/win/scoped_comptr.h instead of base/scoped_comptr_win.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert bad indentation, rebase Created 9 years, 8 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 (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 <atlbase.h> 5 #include <atlbase.h>
6 #include <atlcom.h> 6 #include <atlcom.h>
7 7
8 #include "base/scoped_comptr_win.h" 8 #include "base/threading/thread.h"
9 #include "base/win/scoped_comptr.h"
9 #include "base/win/scoped_handle.h" 10 #include "base/win/scoped_handle.h"
10 #include "base/threading/thread.h"
11 #include "chrome_frame/bho.h" 11 #include "chrome_frame/bho.h"
12 //#include "chrome_frame/urlmon_moniker.h" 12 //#include "chrome_frame/urlmon_moniker.h"
13 #include "chrome_frame/test/chrome_frame_test_utils.h"
13 #include "chrome_frame/test/test_server.h" 14 #include "chrome_frame/test/test_server.h"
14 #include "chrome_frame/test/chrome_frame_test_utils.h"
15 #include "chrome_frame/test/urlmon_moniker_tests.h" 15 #include "chrome_frame/test/urlmon_moniker_tests.h"
16 #include "gmock/gmock.h" 16 #include "gmock/gmock.h"
17 #include "gtest/gtest.h" 17 #include "gtest/gtest.h"
18 18
19 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING 19 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING
20 #include "testing/gmock_mutant.h" 20 #include "testing/gmock_mutant.h"
21 21
22 using testing::_; 22 using testing::_;
23 using testing::CreateFunctor; 23 using testing::CreateFunctor;
24 using testing::Eq; 24 using testing::Eq;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 EXPECT_CALL(callback_, OnStopBinding(data_available_response, _)) 168 EXPECT_CALL(callback_, OnStopBinding(data_available_response, _))
169 .WillOnce(DoAll(QUIT_LOOP(mgr_->loop()), Return(S_OK))); 169 .WillOnce(DoAll(QUIT_LOOP(mgr_->loop()), Return(S_OK)));
170 } else { 170 } else {
171 EXPECT_CALL(callback_, OnStopBinding(data_available_response, _)) 171 EXPECT_CALL(callback_, OnStopBinding(data_available_response, _))
172 .WillOnce(Return(S_OK)); 172 .WillOnce(Return(S_OK));
173 } 173 }
174 } 174 }
175 175
176 HRESULT CreateUrlMonikerAndBindToStorage(const wchar_t* url, 176 HRESULT CreateUrlMonikerAndBindToStorage(const wchar_t* url,
177 IBindCtx** bind_ctx) { 177 IBindCtx** bind_ctx) {
178 ScopedComPtr<IMoniker> moniker; 178 base::win::ScopedComPtr<IMoniker> moniker;
179 HRESULT hr = CreateURLMoniker(NULL, url, moniker.Receive()); 179 HRESULT hr = CreateURLMoniker(NULL, url, moniker.Receive());
180 EXPECT_TRUE(moniker != NULL); 180 EXPECT_TRUE(moniker != NULL);
181 if (moniker) { 181 if (moniker) {
182 ScopedComPtr<IBindCtx> context; 182 base::win::ScopedComPtr<IBindCtx> context;
183 ::CreateAsyncBindCtx(0, callback(), NULL, context.Receive()); 183 ::CreateAsyncBindCtx(0, callback(), NULL, context.Receive());
184 DCHECK(context); 184 DCHECK(context);
185 ScopedComPtr<IStream> stream; 185 base::win::ScopedComPtr<IStream> stream;
186 hr = moniker->BindToStorage(context, NULL, IID_IStream, 186 hr = moniker->BindToStorage(context, NULL, IID_IStream,
187 reinterpret_cast<void**>(stream.Receive())); 187 reinterpret_cast<void**>(stream.Receive()));
188 if (SUCCEEDED(hr) && bind_ctx) 188 if (SUCCEEDED(hr) && bind_ctx)
189 *bind_ctx = context.Detach(); 189 *bind_ctx = context.Detach();
190 } 190 }
191 return hr; 191 return hr;
192 } 192 }
193 193
194 IBindStatusCallback* callback() { 194 IBindStatusCallback* callback() {
195 return &callback_; 195 return &callback_;
(...skipping 12 matching lines...) Expand all
208 const wchar_t test_url[] = L"http://localhost:43210/"; 208 const wchar_t test_url[] = L"http://localhost:43210/";
209 UrlmonMonikerTestManager test(test_url); 209 UrlmonMonikerTestManager test(test_url);
210 UrlmonMonikerTestCallback callback(&test); 210 UrlmonMonikerTestCallback callback(&test);
211 211
212 RunTestServer server_thread; 212 RunTestServer server_thread;
213 EXPECT_TRUE(server_thread.Start()); 213 EXPECT_TRUE(server_thread.Start());
214 214
215 callback.SetCallbackExpectations( 215 callback.SetCallbackExpectations(
216 UrlmonMonikerTestCallback::REQUEST_SYNCHRONOUS, S_OK, false); 216 UrlmonMonikerTestCallback::REQUEST_SYNCHRONOUS, S_OK, false);
217 217
218 ScopedComPtr<IBindCtx> bind_ctx; 218 base::win::ScopedComPtr<IBindCtx> bind_ctx;
219 HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url, 219 HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url,
220 bind_ctx.Receive()); 220 bind_ctx.Receive());
221 // The download should have happened synchronously, so we don't expect 221 // The download should have happened synchronously, so we don't expect
222 // MK_S_ASYNCHRONOUS or any errors. 222 // MK_S_ASYNCHRONOUS or any errors.
223 EXPECT_EQ(S_OK, hr); 223 EXPECT_EQ(S_OK, hr);
224 224
225 IBindCtx* release = bind_ctx.Detach(); 225 IBindCtx* release = bind_ctx.Detach();
226 EXPECT_EQ(0, release->Release()); 226 EXPECT_EQ(0, release->Release());
227 227
228 server_thread.Stop(); 228 server_thread.Stop();
229 } 229 }
230 230
231 // Tests asynchronously binding to a moniker and downloading the target. 231 // Tests asynchronously binding to a moniker and downloading the target.
232 TEST_F(UrlmonMonikerTest, BindToStorageAsynchronous) { 232 TEST_F(UrlmonMonikerTest, BindToStorageAsynchronous) {
233 const wchar_t test_url[] = L"http://localhost:43210/"; 233 const wchar_t test_url[] = L"http://localhost:43210/";
234 UrlmonMonikerTestManager test(test_url); 234 UrlmonMonikerTestManager test(test_url);
235 UrlmonMonikerTestCallback callback(&test); 235 UrlmonMonikerTestCallback callback(&test);
236 236
237 test_server::SimpleWebServer server(43210); 237 test_server::SimpleWebServer server(43210);
238 test_server::SimpleResponse default_response("/", kTestContent); 238 test_server::SimpleResponse default_response("/", kTestContent);
239 server.AddResponse(&default_response); 239 server.AddResponse(&default_response);
240 240
241 callback.SetCallbackExpectations( 241 callback.SetCallbackExpectations(
242 UrlmonMonikerTestCallback::REQUEST_ASYNCHRONOUS, S_OK, true); 242 UrlmonMonikerTestCallback::REQUEST_ASYNCHRONOUS, S_OK, true);
243 243
244 ScopedComPtr<IBindCtx> bind_ctx; 244 base::win::ScopedComPtr<IBindCtx> bind_ctx;
245 HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url, 245 HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url,
246 bind_ctx.Receive()); 246 bind_ctx.Receive());
247 EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); 247 EXPECT_EQ(MK_S_ASYNCHRONOUS, hr);
248 test.loop().RunFor(kUrlmonMonikerTimeoutSec); 248 test.loop().RunFor(kUrlmonMonikerTimeoutSec);
249 249
250 IBindCtx* release = bind_ctx.Detach(); 250 IBindCtx* release = bind_ctx.Detach();
251 EXPECT_EQ(0, release->Release()); 251 EXPECT_EQ(0, release->Release());
252 } 252 }
253 253
254 // Responds with the Chrome mime type. 254 // Responds with the Chrome mime type.
(...skipping 30 matching lines...) Expand all
285 EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); 285 EXPECT_EQ(MK_S_ASYNCHRONOUS, hr);
286 test.loop().RunFor(kUrlmonMonikerTimeoutSec); 286 test.loop().RunFor(kUrlmonMonikerTimeoutSec);
287 287
288 scoped_refptr<RequestData> request_data( 288 scoped_refptr<RequestData> request_data(
289 test.nav_manager().GetActiveRequestData(test_url)); 289 test.nav_manager().GetActiveRequestData(test_url));
290 EXPECT_TRUE(request_data != NULL); 290 EXPECT_TRUE(request_data != NULL);
291 291
292 if (request_data) { 292 if (request_data) {
293 EXPECT_EQ(request_data->GetCachedContentSize(), 293 EXPECT_EQ(request_data->GetCachedContentSize(),
294 arraysize(kTestContent) - 1); 294 arraysize(kTestContent) - 1);
295 ScopedComPtr<IStream> stream; 295 base::win::ScopedComPtr<IStream> stream;
296 request_data->GetResetCachedContentStream(stream.Receive()); 296 request_data->GetResetCachedContentStream(stream.Receive());
297 EXPECT_TRUE(stream != NULL); 297 EXPECT_TRUE(stream != NULL);
298 if (stream) { 298 if (stream) {
299 char buffer[0xffff]; 299 char buffer[0xffff];
300 DWORD read = 0; 300 DWORD read = 0;
301 stream->Read(buffer, sizeof(buffer), &read); 301 stream->Read(buffer, sizeof(buffer), &read);
302 EXPECT_EQ(read, arraysize(kTestContent) - 1); 302 EXPECT_EQ(read, arraysize(kTestContent) - 1);
303 EXPECT_EQ(0, memcmp(buffer, kTestContent, read)); 303 EXPECT_EQ(0, memcmp(buffer, kTestContent, read));
304 } 304 }
305 } 305 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 callback2.SetCallbackExpectations( 339 callback2.SetCallbackExpectations(
340 UrlmonMonikerTestCallback::EXPECT_NO_CALL, S_OK, false); 340 UrlmonMonikerTestCallback::EXPECT_NO_CALL, S_OK, false);
341 hr = callback2.CreateUrlMonikerAndBindToStorage(test_url, NULL); 341 hr = callback2.CreateUrlMonikerAndBindToStorage(test_url, NULL);
342 // S_OK means that the operation completed synchronously. 342 // S_OK means that the operation completed synchronously.
343 // Otherwise we'd get MK_S_ASYNCHRONOUS. 343 // Otherwise we'd get MK_S_ASYNCHRONOUS.
344 EXPECT_EQ(S_OK, hr); 344 EXPECT_EQ(S_OK, hr);
345 } 345 }
346 } 346 }
347 347
348 */ 348 */
OLDNEW
« no previous file with comments | « chrome_frame/test/reliability/page_load_test.cc ('k') | chrome_frame/test/urlmon_moniker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698