Chromium Code Reviews| 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, |