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

Unified Diff: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc

Issue 2407513002: Using ScopedTempDir as the download directory used by the DownloadViaPost test. (Closed)
Patch Set: Inlined CreateAndSetDownloadsDirectory + added PathExists test assert. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
diff --git a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
index f02bb13d2bc6e7160b3690990cbce4dd68a433e9..569f2c3ebd7145b6a9a4201826e31c70d728c707 100644
--- a/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
+++ b/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
@@ -4,6 +4,9 @@
#include <stdint.h>
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
@@ -23,8 +26,10 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/extensions/extension_process_policy.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_frame_host.h"
@@ -991,16 +996,18 @@ IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest,
// GET should automagically start working for downloads.
// TODO(lukasza): https://crbug.com/650694: Add a "Get" flavour of the test once
// the download works both for GET and POST requests.
-
-// Disabled on Windows. See http://crbug.com/653856.
-#if defined(OS_WIN)
-#define MAYBE_DownloadViaPost DISABLED_DownloadViaPost
-#else
-#define MAYBE_DownloadViaPost DownloadViaPost
-#endif
-
-IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest,
- MAYBE_DownloadViaPost) {
+IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest, DownloadViaPost) {
+ // Override the default downloads directory, so that the test can cleanup
+ // after itself. This section is based on CreateAndSetDownloadsDirectory
+ // method defined in a few other source files with tests.
+ base::ScopedTempDir downloads_directory;
+ ASSERT_TRUE(downloads_directory.CreateUniqueTempDir());
+ browser()->profile()->GetPrefs()->SetFilePath(
+ prefs::kDownloadDefaultDirectory, downloads_directory.GetPath());
+ browser()->profile()->GetPrefs()->SetFilePath(
+ prefs::kSaveFileDefaultDirectory, downloads_directory.GetPath());
+
+ // Setup monitoring of the downloads.
content::DownloadTestObserverTerminal downloads_observer(
content::BrowserContext::GetDownloadManager(browser()->profile()),
1, // == wait_count (only waiting for "download-test3.gif").
@@ -1018,6 +1025,8 @@ IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupBrowserTest,
EXPECT_EQ(0u, downloads_observer.NumDangerousDownloadsSeen());
EXPECT_EQ(1u, downloads_observer.NumDownloadsSeenInState(
content::DownloadItem::COMPLETE));
+ EXPECT_TRUE(base::PathExists(downloads_directory.GetPath().AppendASCII(
+ "download-test3-attachment.gif")));
Łukasz Anforowicz 2016/10/07 23:32:03 Inlining / having |downloads_directory| right here
// The test verification below is applicable only to scenarios where the
// download shelf is supported - on ChromeOS, instead of the download shelf,
« 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