Commit 5ada9c49 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Chromium LUCI CQ

capture_mode: Enable testing file ops in unittests

The test delegate should now return a valid temp
directory for the user's downloads dir.

BUG=none
TEST=Existing tests

Change-Id: I159690b0d3bc330e473c33b52f5057cb823a7363
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2587550Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836267}
parent 6b24a068
......@@ -6,6 +6,8 @@
#include "ash/services/recording/public/mojom/recording_service.mojom.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/threading/thread_restrictions.h"
namespace ash {
......@@ -65,13 +67,17 @@ class FakeRecordingService : public recording::mojom::RecordingService {
// -----------------------------------------------------------------------------
// TestCaptureModeDelegate:
TestCaptureModeDelegate::TestCaptureModeDelegate() = default;
TestCaptureModeDelegate::TestCaptureModeDelegate() {
base::ScopedAllowBlockingForTesting allow_blocking;
const bool result =
base::CreateNewTempDirectory(/*prefix=*/"", &fake_downloads_dir_);
DCHECK(result);
}
TestCaptureModeDelegate::~TestCaptureModeDelegate() = default;
base::FilePath TestCaptureModeDelegate::GetActiveUserDownloadsDir() const {
// TODO(afakhry): Add proper code to enable testing.
return base::FilePath();
return fake_downloads_dir_;
}
void TestCaptureModeDelegate::ShowScreenCaptureItemInFolder(
......
......@@ -9,6 +9,7 @@
#include "ash/public/cpp/capture_mode_delegate.h"
#include "base/callback.h"
#include "base/files/file_path.h"
namespace ash {
......@@ -43,6 +44,7 @@ class TestCaptureModeDelegate : public CaptureModeDelegate {
private:
std::unique_ptr<FakeRecordingService> fake_service_;
base::FilePath fake_downloads_dir_;
};
} // namespace ash
......
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