Lines Matching +full:download +full:- +full:url
2 // reserved. Use of this source code is governed by a BSD-style license that
20 const char kTestDomain[] = "test-download.com";
21 const char kTestStartUrl[] = "http://test-download.com/test.html";
22 const char kTestDownloadUrl[] = "http://test-download.com/download.txt";
23 const char kTestNavUrl[] = "http://test-download-nav.com/nav.html";
28 const char kTestContent[] = "Download test text";
46 std::string url = request->GetURL(); in Open() local
47 if (url == kTestDownloadUrl) { in Open()
48 got_download_request_->yes(); in Open()
71 response->SetStatus(200); in GetResponseHeaders()
72 response->SetMimeType(mime_type_); in GetResponseHeaders()
76 response->GetHeaderMap(headerMap); in GetResponseHeaders()
78 std::make_pair("Content-Disposition", content_disposition_)); in GetResponseHeaders()
79 response->SetHeaderMap(headerMap); in GetResponseHeaders()
92 // Delay the download response a single time. in Read()
110 callback->Continue(bytes_read); in ContinueRead()
118 std::min(bytes_to_read, static_cast<int>(size - offset_)); in DoRead()
209 request_context->RegisterSchemeHandlerFactory("http", kTestDomain, in RunTest()
229 std::string url; in RunTest() local
231 url = kTestDownloadUrl; in RunTest()
233 url = "invalid:foo@example.com"; in RunTest()
239 "<html><body><a href=\"" + url + "\">CLICK ME</a></body></html>", in RunTest()
242 AddResource(kTestStartUrl, "<html><body>Download Test</body></html>", in RunTest()
256 const std::string& url = frame->GetURL().ToString(); in OnLoadEnd() local
257 if (url == kTestNavUrl) { in OnLoadEnd()
264 // Begin the download by clicking a link. in OnLoadEnd()
265 // ALT key will trigger download of custom protocol links. in OnLoadEnd()
277 // Begin the download progammatically. in OnLoadEnd()
278 browser->GetHost()->StartDownload(kTestDownloadUrl); in OnLoadEnd()
282 // Callback from the scheme handler when the download request is delayed.
314 // Destroy the test without waiting for the download to complete. in ContinuePendingIfReady()
329 EXPECT_TRUE(browser->IsSame(GetBrowser())); in OnBeforeDownload()
334 download_id_ = download_item->GetId(); in OnBeforeDownload()
337 EXPECT_TRUE(download_item->IsValid()); in OnBeforeDownload()
338 EXPECT_TRUE(download_item->IsInProgress()); in OnBeforeDownload()
339 EXPECT_FALSE(download_item->IsComplete()); in OnBeforeDownload()
340 EXPECT_FALSE(download_item->IsCanceled()); in OnBeforeDownload()
341 EXPECT_EQ(static_cast<int64>(sizeof(kTestContent) - 1), in OnBeforeDownload()
342 download_item->GetTotalBytes()); in OnBeforeDownload()
343 EXPECT_EQ(0UL, download_item->GetFullPath().length()); in OnBeforeDownload()
344 EXPECT_STREQ(kTestDownloadUrl, download_item->GetURL().ToString().c_str()); in OnBeforeDownload()
345 EXPECT_EQ(0UL, download_item->GetSuggestedFileName().length()); in OnBeforeDownload()
347 download_item->GetContentDisposition().ToString().c_str()); in OnBeforeDownload()
349 download_item->GetMimeType().ToString().c_str()); in OnBeforeDownload()
351 callback->Continue(test_path_, false); in OnBeforeDownload()
354 CefRefPtr<CefFrame> main_frame = browser->GetMainFrame(); in OnBeforeDownload()
355 EXPECT_TRUE(main_frame->IsMain()); in OnBeforeDownload()
356 main_frame->LoadURL(kTestNavUrl); in OnBeforeDownload()
372 EXPECT_TRUE(browser->IsSame(GetBrowser())); in OnDownloadUpdated()
377 EXPECT_EQ(download_id_, download_item->GetId()); in OnDownloadUpdated()
380 EXPECT_LE(0LL, download_item->GetCurrentSpeed()); in OnDownloadUpdated()
381 EXPECT_LE(0, download_item->GetPercentComplete()); in OnDownloadUpdated()
383 EXPECT_TRUE(download_item->IsValid()); in OnDownloadUpdated()
384 EXPECT_FALSE(download_item->IsCanceled()); in OnDownloadUpdated()
385 EXPECT_STREQ(kTestDownloadUrl, download_item->GetURL().ToString().c_str()); in OnDownloadUpdated()
387 download_item->GetContentDisposition().ToString().c_str()); in OnDownloadUpdated()
389 download_item->GetMimeType().ToString().c_str()); in OnDownloadUpdated()
391 std::string full_path = download_item->GetFullPath(); in OnDownloadUpdated()
397 if (download_item->IsComplete()) { in OnDownloadUpdated()
400 EXPECT_FALSE(download_item->IsInProgress()); in OnDownloadUpdated()
401 EXPECT_EQ(100, download_item->GetPercentComplete()); in OnDownloadUpdated()
402 EXPECT_EQ(static_cast<int64>(sizeof(kTestContent) - 1), in OnDownloadUpdated()
403 download_item->GetReceivedBytes()); in OnDownloadUpdated()
404 EXPECT_EQ(static_cast<int64>(sizeof(kTestContent) - 1), in OnDownloadUpdated()
405 download_item->GetTotalBytes()); in OnDownloadUpdated()
409 EXPECT_TRUE(download_item->IsInProgress()); in OnDownloadUpdated()
410 EXPECT_LE(0LL, download_item->GetReceivedBytes()); in OnDownloadUpdated()
450 // Cancel the pending download to avoid leaking request objects. in DestroyTest()
451 download_item_callback_->Cancel(); in DestroyTest()
456 request_context_->RegisterSchemeHandlerFactory("http", kTestDomain, in DestroyTest()
500 base::BindOnce(&CefBrowserHost::SendMouseClickEvent, browser->GetHost(), in SendClick()
505 base::BindOnce(&CefBrowserHost::SendMouseClickEvent, browser->GetHost(), in SendClick()
544 // Test a programmatic download.
547 // Test a clicked download.
550 // Test a clicked download where the protocol is invalid and therefore rejected.
554 // Test where the download completes after cross-origin navigation.
557 // Test where the download is still pending when the browser is destroyed.