chromium/chrome/browser/extensions/api/image_writer_private/test_utils.h

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_
#define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_

#include <stdint.h>

#include <memory>

#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/api/image_writer_private/image_writer_utility_client.h"
#include "chrome/browser/extensions/api/image_writer_private/operation_manager.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "extensions/common/extension_id.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/disks/disk_mount_manager.h"
#include "chromeos/ash/components/disks/mock_disk_mount_manager.h"
#endif

namespace extensions {
namespace image_writer {

#if BUILDFLAG(IS_CHROMEOS_ASH)
class ImageWriterFakeImageBurnerClient;
#endif

const char kDummyExtensionId[] =;

// Default file size to use in tests.  Currently 32kB.
const size_t kTestFileSize =;
// Pattern to use in the image file.
const uint8_t kImagePattern =;  // 01010101
// Pattern to use in the device file.
const uint8_t kDevicePattern =;  // 10101010
// Disk file system type
const char kTestFileSystemType[] =;

// A mock around the operation manager for tracking callbacks.  Note that there
// are non-virtual methods on this class that should not be called in tests.
class MockOperationManager : public OperationManager {};

#if BUILDFLAG(IS_CHROMEOS_ASH)
// A fake for the DiskMountManager that will successfully call the unmount
// callback.
class FakeDiskMountManager : public ash::disks::MockDiskMountManager {
 public:
  FakeDiskMountManager();
  ~FakeDiskMountManager() override;

  void UnmountDeviceRecursively(
      const std::string& device_path,
      UnmountDeviceRecursivelyCallbackType callback) override;

 private:
  Disks disks_;
};
#endif

struct SimulateProgressInfo {};

class FakeImageWriterClient : public ImageWriterUtilityClient {};

class ImageWriterTestUtils {};

// Base class for unit tests that manages creating image and device files.
class ImageWriterUnitTestBase : public testing::Test {};

bool GetTestDataDirectory(base::FilePath* path);

}  // namespace image_writer
}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_