Commit 99d09111 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Local NTP download test: don't leak downloaded files

Before this CL, LocalNTPTest.EmbeddedSearchAPIAfterDownload stored a
test download file into the system's actual downloads folder, and left
it there after the test ended. This CL instead sets up a temporary
folder as the download folder.

Bug: 592273
Change-Id: I27aa103b4c69b7c6a6bba755f74ee0bcb9fe2c84
Reviewed-on: https://chromium-review.googlesource.com/814115Reviewed-by: default avatarChris Pickel <sfiera@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522424}
parent f5b15523
......@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/scoped_temp_dir.h"
#include "base/i18n/base_i18n_switches.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/statistics_recorder.h"
......@@ -14,6 +15,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/test/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/instant_service.h"
......@@ -25,11 +27,13 @@
#include "chrome/browser/ui/search/instant_test_utils.h"
#include "chrome/browser/ui/search/local_ntp_test_utils.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/search/instant_types.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/interstitial_page_delegate.h"
......@@ -251,6 +255,14 @@ IN_PROC_BROWSER_TEST_F(LocalNTPTest, EmbeddedSearchAPIEndToEnd) {
// Regression test for crbug.com/592273.
IN_PROC_BROWSER_TEST_F(LocalNTPTest, EmbeddedSearchAPIAfterDownload) {
// Set up a temporary directory for downloads, so that we don't leak the
// downloaded file.
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir downloads_dir;
ASSERT_TRUE(downloads_dir.CreateUniqueTempDir());
browser()->profile()->GetPrefs()->SetFilePath(
prefs::kDownloadDefaultDirectory, downloads_dir.GetPath());
// Set up a test server, so we have some URL to download.
net::EmbeddedTestServer test_server(net::EmbeddedTestServer::TYPE_HTTPS);
test_server.ServeFilesFromSourceDirectory("chrome/test/data");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment