| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/scoped_comptr_win.h" |
| 9 #include "base/thread.h" | 9 #include "base/thread.h" |
| 10 #include "chrome_frame/bho.h" | 10 #include "chrome_frame/bho.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 bind_ctx.Receive()); | 239 bind_ctx.Receive()); |
| 240 EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); | 240 EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); |
| 241 test.loop().RunFor(kUrlmonMonikerTimeoutSec); | 241 test.loop().RunFor(kUrlmonMonikerTimeoutSec); |
| 242 | 242 |
| 243 IBindCtx* release = bind_ctx.Detach(); | 243 IBindCtx* release = bind_ctx.Detach(); |
| 244 EXPECT_EQ(0, release->Release()); | 244 EXPECT_EQ(0, release->Release()); |
| 245 | 245 |
| 246 EXPECT_FALSE(test.nav_manager().HasRequestData()); | 246 EXPECT_FALSE(test.nav_manager().HasRequestData()); |
| 247 } | 247 } |
| 248 | 248 |
| 249 // Responds with the Chrome mime type. |
| 250 class ResponseWithContentType : public test_server::SimpleResponse { |
| 251 public: |
| 252 ResponseWithContentType(const char* request_path, |
| 253 const std::string& contents) |
| 254 : test_server::SimpleResponse(request_path, contents) { |
| 255 } |
| 256 virtual bool GetContentType(std::string* content_type) const { |
| 257 *content_type = WideToASCII(kChromeMimeType); |
| 258 return true; |
| 259 } |
| 260 }; |
| 261 |
| 249 // Downloads a document asynchronously and then verifies that the downloaded | 262 // Downloads a document asynchronously and then verifies that the downloaded |
| 250 // contents were cached and the cache contents are correct. | 263 // contents were cached and the cache contents are correct. |
| 251 // TODO(tommi): Fix and re-enable. | 264 // TODO(tommi): Fix and re-enable. |
| 252 // http://code.google.com/p/chromium/issues/detail?id=39415 | 265 // http://code.google.com/p/chromium/issues/detail?id=39415 |
| 253 TEST_F(UrlmonMonikerTest, DISABLED_BindToStorageSwitchContent) { | 266 TEST_F(UrlmonMonikerTest, BindToStorageSwitchContent) { |
| 254 const wchar_t test_url[] = L"http://localhost:43210/"; | 267 const wchar_t test_url[] = L"http://localhost:43210/"; |
| 255 UrlmonMonikerTestManager test(test_url); | 268 UrlmonMonikerTestManager test(test_url); |
| 256 UrlmonMonikerTestCallback callback(&test); | 269 UrlmonMonikerTestCallback callback(&test); |
| 257 | 270 |
| 258 test_server::SimpleWebServer server(43210); | 271 test_server::SimpleWebServer server(43210); |
| 259 test_server::SimpleResponse default_response("/", kTestContent); | 272 ResponseWithContentType default_response("/", kTestContent); |
| 260 server.AddResponse(&default_response); | 273 server.AddResponse(&default_response); |
| 261 | 274 |
| 262 callback.SetCallbackExpectations( | 275 callback.SetCallbackExpectations( |
| 263 UrlmonMonikerTestCallback::REQUEST_ASYNCHRONOUS, INET_E_TERMINATED_BIND, | 276 UrlmonMonikerTestCallback::REQUEST_ASYNCHRONOUS, INET_E_TERMINATED_BIND, |
| 264 true); | 277 true); |
| 265 | 278 |
| 266 HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url, NULL); | 279 HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url, NULL); |
| 267 EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); | 280 EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); |
| 268 test.loop().RunFor(kUrlmonMonikerTimeoutSec); | 281 test.loop().RunFor(kUrlmonMonikerTimeoutSec); |
| 269 | 282 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 289 | 302 |
| 290 // Fetches content asynchronously first to cache it and then | 303 // Fetches content asynchronously first to cache it and then |
| 291 // verifies that fetching the cached content the same way works as expected | 304 // verifies that fetching the cached content the same way works as expected |
| 292 // and happens synchronously. | 305 // and happens synchronously. |
| 293 TEST_F(UrlmonMonikerTest, BindToStorageCachedContent) { | 306 TEST_F(UrlmonMonikerTest, BindToStorageCachedContent) { |
| 294 const wchar_t test_url[] = L"http://localhost:43210/"; | 307 const wchar_t test_url[] = L"http://localhost:43210/"; |
| 295 UrlmonMonikerTestManager test(test_url); | 308 UrlmonMonikerTestManager test(test_url); |
| 296 UrlmonMonikerTestCallback callback(&test); | 309 UrlmonMonikerTestCallback callback(&test); |
| 297 | 310 |
| 298 test_server::SimpleWebServer server(43210); | 311 test_server::SimpleWebServer server(43210); |
| 299 test_server::SimpleResponse default_response("/", kTestContent); | 312 ResponseWithContentType default_response("/", kTestContent); |
| 300 server.AddResponse(&default_response); | 313 server.AddResponse(&default_response); |
| 301 | 314 |
| 302 // First set of expectations. Download the contents | 315 // First set of expectations. Download the contents |
| 303 // asynchronously. This should populate the cache so that | 316 // asynchronously. This should populate the cache so that |
| 304 // the second request should be served synchronously without | 317 // the second request should be served synchronously without |
| 305 // going to the server. | 318 // going to the server. |
| 306 callback.SetCallbackExpectations( | 319 callback.SetCallbackExpectations( |
| 307 UrlmonMonikerTestCallback::REQUEST_ASYNCHRONOUS, INET_E_TERMINATED_BIND, | 320 UrlmonMonikerTestCallback::REQUEST_ASYNCHRONOUS, INET_E_TERMINATED_BIND, |
| 308 true); | 321 true); |
| 309 | 322 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 320 UrlmonMonikerTestCallback callback2(&test); | 333 UrlmonMonikerTestCallback callback2(&test); |
| 321 callback2.SetCallbackExpectations( | 334 callback2.SetCallbackExpectations( |
| 322 UrlmonMonikerTestCallback::EXPECT_NO_CALL, S_OK, false); | 335 UrlmonMonikerTestCallback::EXPECT_NO_CALL, S_OK, false); |
| 323 hr = callback2.CreateUrlMonikerAndBindToStorage(test_url, NULL); | 336 hr = callback2.CreateUrlMonikerAndBindToStorage(test_url, NULL); |
| 324 // S_OK means that the operation completed synchronously. | 337 // S_OK means that the operation completed synchronously. |
| 325 // Otherwise we'd get MK_S_ASYNCHRONOUS. | 338 // Otherwise we'd get MK_S_ASYNCHRONOUS. |
| 326 EXPECT_EQ(S_OK, hr); | 339 EXPECT_EQ(S_OK, hr); |
| 327 } | 340 } |
| 328 } | 341 } |
| 329 | 342 |
| OLD | NEW |