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

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 197883010: Add browsertest for the feedback service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded complexity Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 28 matching lines...) Expand all
39 #include "chrome/browser/download/download_test_file_activity_observer.h" 39 #include "chrome/browser/download/download_test_file_activity_observer.h"
40 #include "chrome/browser/extensions/extension_install_prompt.h" 40 #include "chrome/browser/extensions/extension_install_prompt.h"
41 #include "chrome/browser/extensions/extension_service.h" 41 #include "chrome/browser/extensions/extension_service.h"
42 #include "chrome/browser/history/download_row.h" 42 #include "chrome/browser/history/download_row.h"
43 #include "chrome/browser/history/history_service.h" 43 #include "chrome/browser/history/history_service.h"
44 #include "chrome/browser/history/history_service_factory.h" 44 #include "chrome/browser/history/history_service_factory.h"
45 #include "chrome/browser/infobars/infobar_service.h" 45 #include "chrome/browser/infobars/infobar_service.h"
46 #include "chrome/browser/net/url_request_mock_util.h" 46 #include "chrome/browser/net/url_request_mock_util.h"
47 #include "chrome/browser/profiles/profile.h" 47 #include "chrome/browser/profiles/profile.h"
48 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h" 48 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti l.h"
49 #include "chrome/browser/safe_browsing/download_feedback_service.h"
50 #include "chrome/browser/safe_browsing/download_protection_service.h"
51 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
49 #include "chrome/browser/ui/browser.h" 52 #include "chrome/browser/ui/browser.h"
50 #include "chrome/browser/ui/browser_commands.h" 53 #include "chrome/browser/ui/browser_commands.h"
51 #include "chrome/browser/ui/browser_finder.h" 54 #include "chrome/browser/ui/browser_finder.h"
52 #include "chrome/browser/ui/browser_list.h" 55 #include "chrome/browser/ui/browser_list.h"
53 #include "chrome/browser/ui/browser_tabstrip.h" 56 #include "chrome/browser/ui/browser_tabstrip.h"
54 #include "chrome/browser/ui/browser_window.h" 57 #include "chrome/browser/ui/browser_window.h"
55 #include "chrome/browser/ui/chrome_pages.h" 58 #include "chrome/browser/ui/chrome_pages.h"
56 #include "chrome/browser/ui/host_desktop.h" 59 #include "chrome/browser/ui/host_desktop.h"
57 #include "chrome/browser/ui/tabs/tab_strip_model.h" 60 #include "chrome/browser/ui/tabs/tab_strip_model.h"
58 #include "chrome/common/chrome_paths.h" 61 #include "chrome/common/chrome_paths.h"
59 #include "chrome/common/pref_names.h" 62 #include "chrome/common/pref_names.h"
63 #include "chrome/common/safe_browsing/csd.pb.h"
60 #include "chrome/common/url_constants.h" 64 #include "chrome/common/url_constants.h"
61 #include "chrome/test/base/in_process_browser_test.h" 65 #include "chrome/test/base/in_process_browser_test.h"
62 #include "chrome/test/base/test_switches.h" 66 #include "chrome/test/base/test_switches.h"
63 #include "chrome/test/base/ui_test_utils.h" 67 #include "chrome/test/base/ui_test_utils.h"
64 #include "components/infobars/core/confirm_infobar_delegate.h" 68 #include "components/infobars/core/confirm_infobar_delegate.h"
65 #include "components/infobars/core/infobar.h" 69 #include "components/infobars/core/infobar.h"
66 #include "content/public/browser/download_interrupt_reasons.h" 70 #include "content/public/browser/download_interrupt_reasons.h"
67 #include "content/public/browser/download_item.h" 71 #include "content/public/browser/download_item.h"
68 #include "content/public/browser/download_manager.h" 72 #include "content/public/browser/download_manager.h"
69 #include "content/public/browser/download_save_info.h" 73 #include "content/public/browser/download_save_info.h"
(...skipping 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3224 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_GZipWithNoContent) { 3228 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_GZipWithNoContent) {
3225 ASSERT_TRUE(test_server()->Start()); 3229 ASSERT_TRUE(test_server()->Start());
3226 GURL url(test_server()->GetURL("files/downloads/empty.bin")); 3230 GURL url(test_server()->GetURL("files/downloads/empty.bin"));
3227 // Downloading the same URL twice causes the second request to be served from 3231 // Downloading the same URL twice causes the second request to be served from
3228 // cached (with a high probability). This test verifies that that doesn't 3232 // cached (with a high probability). This test verifies that that doesn't
3229 // happen regardless of whether the request is served via the cache or from 3233 // happen regardless of whether the request is served via the cache or from
3230 // the network. 3234 // the network.
3231 DownloadAndWait(browser(), url); 3235 DownloadAndWait(browser(), url);
3232 DownloadAndWait(browser(), url); 3236 DownloadAndWait(browser(), url);
3233 } 3237 }
3238
3239 #if defined(FULL_SAFE_BROWSING)
3240 IN_PROC_BROWSER_TEST_F(DownloadTest, FeedbackService) {
3241 // Make a dangerous file.
3242 base::FilePath file(FILE_PATH_LITERAL("downloads/dangerous/dangerous.swf"));
3243 GURL download_url(content::URLRequestMockHTTPJob::GetMockUrl(file));
3244 scoped_ptr<content::DownloadTestObserverInterrupted> observer(
3245 new content::DownloadTestObserverInterrupted(
3246 DownloadManagerForBrowser(browser()), 1,
3247 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_QUIT));
3248 ui_test_utils::NavigateToURLWithDisposition(
3249 browser(),
3250 GURL(download_url),
3251 NEW_BACKGROUND_TAB,
3252 ui_test_utils::BROWSER_TEST_NONE);
3253 observer->WaitForFinished();
3254
3255 // Get the download from the DownloadManager.
3256 std::vector<DownloadItem*> downloads;
3257 DownloadManagerForBrowser(browser())->GetAllDownloads(&downloads);
3258 ASSERT_EQ(1u, downloads.size());
3259 EXPECT_TRUE(downloads[0]->IsDangerous());
3260
3261 // Save fake pings for the download.
3262 safe_browsing::ClientDownloadReport fake_metadata;
3263 fake_metadata.mutable_download_request()->set_url("http://test");
3264 fake_metadata.mutable_download_request()->set_length(1);
3265 fake_metadata.mutable_download_request()->mutable_digests()->set_sha1("hi");
3266 fake_metadata.mutable_download_response()->set_verdict(
3267 safe_browsing::ClientDownloadResponse::UNCOMMON);
3268 std::string ping_request(
3269 fake_metadata.download_request().SerializeAsString());
3270 std::string ping_response(
3271 fake_metadata.download_response().SerializeAsString());
3272 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service();
3273 safe_browsing::DownloadProtectionService* download_protection_service =
3274 sb_service->download_protection_service();
3275 download_protection_service->feedback_service()->MaybeStorePingsForDownload(
3276 safe_browsing::DownloadProtectionService::UNCOMMON,
3277 downloads[0],
3278 ping_request,
3279 ping_response);
3280 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload(
3281 *(downloads[0])));
3282
3283 // Begin feedback and check that the file is "stolen".
3284 download_protection_service->feedback_service()->BeginFeedbackForDownload(
3285 downloads[0]);
3286 std::vector<DownloadItem*> updated_downloads;
3287 GetDownloads(browser(), &updated_downloads);
3288 ASSERT_TRUE(updated_downloads.empty());
3289 }
3290 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698