| 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 9cbfe71b08382da2e372b61646a7c3d1b3ec9721..876abcc72a4f205de1a94ac1b907498804f73956 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"
|
| @@ -64,6 +69,18 @@ void ExecuteExtensionAction(Browser* browser, const Extension* extension) {
|
| ->RunAction(extension, true);
|
| }
|
|
|
| +std::unique_ptr<base::ScopedTempDir> CreateAndSetDownloadsDirectory(
|
| + PrefService* pref_service) {
|
| + std::unique_ptr<base::ScopedTempDir> dir(new base::ScopedTempDir);
|
| +
|
| + if (!dir->CreateUniqueTempDir())
|
| + return nullptr;
|
| +
|
| + pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, dir->GetPath());
|
| + pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, dir->GetPath());
|
| + return dir;
|
| +}
|
| +
|
| // An ImageSkia source that will do nothing (i.e., have a blank skia). We need
|
| // this because we need a blank canvas at a certain size, and that can't be done
|
| // by just using a null ImageSkia.
|
| @@ -991,16 +1008,15 @@ 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 and Mac. See http://crbug.com/653856.
|
| -#if defined(OS_WIN) || defined(OS_MACOSX)
|
| -#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.
|
| + std::unique_ptr<base::ScopedTempDir> downloads_directory =
|
| + CreateAndSetDownloadsDirectory(browser()->profile()->GetPrefs());
|
| + ASSERT_TRUE(downloads_directory);
|
| +
|
| + // 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 +1034,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")));
|
|
|
| // The test verification below is applicable only to scenarios where the
|
| // download shelf is supported - on ChromeOS, instead of the download shelf,
|
|
|