Commit 5ae14aec authored by Alexander Dunaev's avatar Alexander Dunaev Committed by Commit Bot

[ozone] Fixed the DownloadManager tests.

This CL unifies the behaviour and test expectations for the Download
Manager on Linux platforms.

Bug: 1109690
Change-Id: I45802dbc640c25b2b64384b5bfeb1dfccc9983e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2465855
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Auto-Submit: Alexander Dunaev <adunaev@igalia.com>
Cr-Commit-Position: refs/heads/master@{#816599}
parent fc7261db
...@@ -82,9 +82,8 @@ ...@@ -82,9 +82,8 @@
#include "third_party/blink/public/common/loader/referrer_utils.h" #include "third_party/blink/public/common/loader/referrer_utils.h"
#include "third_party/blink/public/common/loader/throttling_url_loader.h" #include "third_party/blink/public/common/loader/throttling_url_loader.h"
#if defined(USE_X11) #if defined(OS_LINUX)
#include "base/nix/xdg_util.h" #include "base/nix/xdg_util.h"
#include "ui/base/ui_base_features.h"
#endif #endif
namespace content { namespace content {
...@@ -219,7 +218,7 @@ class DownloadItemFactoryImpl : public download::DownloadItemFactory { ...@@ -219,7 +218,7 @@ class DownloadItemFactoryImpl : public download::DownloadItemFactory {
} }
}; };
#if defined(USE_X11) #if defined(OS_LINUX)
base::FilePath GetTemporaryDownloadDirectory() { base::FilePath GetTemporaryDownloadDirectory() {
std::unique_ptr<base::Environment> env(base::Environment::Create()); std::unique_ptr<base::Environment> env(base::Environment::Create());
return base::nix::GetXDGDirectory(env.get(), "XDG_DATA_HOME", ".local/share"); return base::nix::GetXDGDirectory(env.get(), "XDG_DATA_HOME", ".local/share");
...@@ -560,13 +559,12 @@ bool DownloadManagerImpl::InterceptDownload( ...@@ -560,13 +559,12 @@ bool DownloadManagerImpl::InterceptDownload(
base::FilePath DownloadManagerImpl::GetDefaultDownloadDirectory() { base::FilePath DownloadManagerImpl::GetDefaultDownloadDirectory() {
base::FilePath default_download_directory; base::FilePath default_download_directory;
#if defined(USE_X11) #if defined(OS_LINUX)
// TODO(thomasanderson,crbug.com/784010): Remove this when all Linux // TODO(thomasanderson,crbug.com/784010): Remove this when all Linux
// distros with versions of GTK lower than 3.14.7 are no longer // distros with versions of GTK lower than 3.14.7 are no longer
// supported. This should happen when support for Ubuntu Trusty and // supported. This should happen when support for Ubuntu Trusty and
// Debian Jessie are removed. // Debian Jessie are removed.
if (!features::IsUsingOzonePlatform()) default_download_directory = GetTemporaryDownloadDirectory();
default_download_directory = GetTemporaryDownloadDirectory();
#endif #endif
if (delegate_ && default_download_directory.empty()) { if (delegate_ && default_download_directory.empty()) {
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_context.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_features.h"
#include "url/origin.h" #include "url/origin.h"
using base::test::RunOnceCallback; using base::test::RunOnceCallback;
...@@ -608,16 +607,17 @@ TEST_F(DownloadManagerTest, StartDownload) { ...@@ -608,16 +607,17 @@ TEST_F(DownloadManagerTest, StartDownload) {
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetNextId_(_)) EXPECT_CALL(GetMockDownloadManagerDelegate(), GetNextId_(_))
.WillOnce(RunOnceCallback<0>(local_id)); .WillOnce(RunOnceCallback<0>(local_id));
// TODO(https://crbug.com/1109690): figure out what to do for Ozone/Linux. // TODO(thomasanderson,crbug.com/784010): Remove this when all Linux
// Probably, this can be removed. // distros with versions of GTK lower than 3.14.7 are no longer
bool should_call_get_save_dir = true; // supported. This should happen when support for Ubuntu Trusty and
#if defined(USE_X11) // Debian Jessie are removed.
should_call_get_save_dir = features::IsUsingOzonePlatform(); #if defined(OS_LINUX)
// Doing nothing will set the default download directory to null.
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _)).Times(0);
#else
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _));
#endif #endif
if (should_call_get_save_dir) {
// Doing nothing will set the default download directory to null.
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _));
}
EXPECT_CALL(GetMockDownloadManagerDelegate(), EXPECT_CALL(GetMockDownloadManagerDelegate(),
ApplicationClientIdForFileScanning()) ApplicationClientIdForFileScanning())
.WillRepeatedly(Return("client-id")); .WillRepeatedly(Return("client-id"));
...@@ -650,16 +650,17 @@ TEST_F(DownloadManagerTest, StartDownloadWithoutHistoryDB) { ...@@ -650,16 +650,17 @@ TEST_F(DownloadManagerTest, StartDownloadWithoutHistoryDB) {
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetNextId_(_)) EXPECT_CALL(GetMockDownloadManagerDelegate(), GetNextId_(_))
.WillOnce(RunOnceCallback<0>(download::DownloadItem::kInvalidId)); .WillOnce(RunOnceCallback<0>(download::DownloadItem::kInvalidId));
// TODO(https://crbug.com/1109690): figure out what to do for Ozone/Linux. // TODO(thomasanderson,crbug.com/784010): Remove this when all Linux
// Probably, this can be removed. // distros with versions of GTK lower than 3.14.7 are no longer
bool should_call_get_save_dir = true; // supported. This should happen when support for Ubuntu Trusty and
#if defined(USE_X11) // Debian Jessie are removed.
should_call_get_save_dir = features::IsUsingOzonePlatform(); #if defined(OS_LINUX)
// Doing nothing will set the default download directory to null.
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _)).Times(0);
#else
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _));
#endif #endif
if (should_call_get_save_dir) {
// Doing nothing will set the default download directory to null.
EXPECT_CALL(GetMockDownloadManagerDelegate(), GetSaveDir(_, _, _));
}
EXPECT_CALL(GetMockDownloadManagerDelegate(), EXPECT_CALL(GetMockDownloadManagerDelegate(),
ApplicationClientIdForFileScanning()) ApplicationClientIdForFileScanning())
.WillRepeatedly(Return("client-id")); .WillRepeatedly(Return("client-id"));
......
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