test_media_transfer_protocol_manager_chromeos.cc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/storage_monitor/test_media_transfer_protocol_manager_chromeos.h"
  5. #include <memory>
  6. #include <utility>
  7. #include <vector>
  8. #include "base/no_destructor.h"
  9. #include "services/device/public/mojom/mtp_file_entry.mojom.h"
  10. #include "services/device/public/mojom/mtp_storage_info.mojom.h"
  11. namespace storage_monitor {
  12. // static
  13. TestMediaTransferProtocolManagerChromeOS*
  14. TestMediaTransferProtocolManagerChromeOS::GetFakeMtpManager() {
  15. static base::NoDestructor<TestMediaTransferProtocolManagerChromeOS>
  16. fake_mtp_manager;
  17. return fake_mtp_manager.get();
  18. }
  19. TestMediaTransferProtocolManagerChromeOS::
  20. TestMediaTransferProtocolManagerChromeOS() {}
  21. TestMediaTransferProtocolManagerChromeOS::
  22. ~TestMediaTransferProtocolManagerChromeOS() {}
  23. void TestMediaTransferProtocolManagerChromeOS::AddReceiver(
  24. mojo::PendingReceiver<device::mojom::MtpManager> receiver) {
  25. receivers_.Add(this, std::move(receiver));
  26. }
  27. void TestMediaTransferProtocolManagerChromeOS::EnumerateStoragesAndSetClient(
  28. mojo::PendingAssociatedRemote<device::mojom::MtpManagerClient> client,
  29. EnumerateStoragesAndSetClientCallback callback) {
  30. std::move(callback).Run(std::vector<device::mojom::MtpStorageInfoPtr>());
  31. }
  32. void TestMediaTransferProtocolManagerChromeOS::GetStorageInfo(
  33. const std::string& storage_name,
  34. GetStorageInfoCallback callback) {
  35. std::move(callback).Run(nullptr);
  36. }
  37. void TestMediaTransferProtocolManagerChromeOS::GetStorageInfoFromDevice(
  38. const std::string& storage_name,
  39. GetStorageInfoFromDeviceCallback callback) {
  40. std::move(callback).Run(device::mojom::MtpStorageInfo::New(),
  41. true /* error */);
  42. }
  43. void TestMediaTransferProtocolManagerChromeOS::OpenStorage(
  44. const std::string& storage_name,
  45. const std::string& mode,
  46. OpenStorageCallback callback) {
  47. std::move(callback).Run("", true);
  48. }
  49. void TestMediaTransferProtocolManagerChromeOS::CloseStorage(
  50. const std::string& storage_handle,
  51. CloseStorageCallback callback) {
  52. std::move(callback).Run(true);
  53. }
  54. void TestMediaTransferProtocolManagerChromeOS::CreateDirectory(
  55. const std::string& storage_handle,
  56. uint32_t parent_id,
  57. const std::string& directory_name,
  58. CreateDirectoryCallback callback) {
  59. std::move(callback).Run(true /* error */);
  60. }
  61. void TestMediaTransferProtocolManagerChromeOS::ReadDirectoryEntryIds(
  62. const std::string& storage_handle,
  63. uint32_t file_id,
  64. ReadDirectoryEntryIdsCallback callback) {
  65. std::move(callback).Run(std::vector<uint32_t>(), /*error=*/true);
  66. }
  67. void TestMediaTransferProtocolManagerChromeOS::ReadFileChunk(
  68. const std::string& storage_handle,
  69. uint32_t file_id,
  70. uint32_t offset,
  71. uint32_t count,
  72. ReadFileChunkCallback callback) {
  73. std::move(callback).Run(std::string(), true);
  74. }
  75. void TestMediaTransferProtocolManagerChromeOS::GetFileInfo(
  76. const std::string& storage_handle,
  77. const std::vector<uint32_t>& file_ids,
  78. GetFileInfoCallback callback) {
  79. std::move(callback).Run(std::vector<device::mojom::MtpFileEntryPtr>(), true);
  80. }
  81. void TestMediaTransferProtocolManagerChromeOS::RenameObject(
  82. const std::string& storage_handle,
  83. uint32_t object_id,
  84. const std::string& new_name,
  85. RenameObjectCallback callback) {
  86. std::move(callback).Run(true /* error */);
  87. }
  88. void TestMediaTransferProtocolManagerChromeOS::CopyFileFromLocal(
  89. const std::string& storage_handle,
  90. int64_t source_file_descriptor,
  91. uint32_t parent_id,
  92. const std::string& file_name,
  93. CopyFileFromLocalCallback callback) {
  94. std::move(callback).Run(true /* error */);
  95. }
  96. void TestMediaTransferProtocolManagerChromeOS::DeleteObject(
  97. const std::string& storage_handle,
  98. uint32_t object_id,
  99. DeleteObjectCallback callback) {
  100. std::move(callback).Run(true /* error */);
  101. }
  102. } // namespace storage_monitor