test_volume_mount_watcher_win.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. //
  5. // This file contains a subclass of VolumeMountWatcherWin to expose some
  6. // functionality for testing.
  7. #ifndef COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_
  8. #define COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_
  9. #include <stdint.h>
  10. #include <memory>
  11. #include <string>
  12. #include <vector>
  13. #include "base/synchronization/waitable_event.h"
  14. #include "components/storage_monitor/volume_mount_watcher_win.h"
  15. namespace base {
  16. class FilePath;
  17. }
  18. namespace storage_monitor {
  19. class TestVolumeMountWatcherWin : public VolumeMountWatcherWin {
  20. public:
  21. TestVolumeMountWatcherWin();
  22. TestVolumeMountWatcherWin(const TestVolumeMountWatcherWin&) = delete;
  23. TestVolumeMountWatcherWin& operator=(const TestVolumeMountWatcherWin&) =
  24. delete;
  25. ~TestVolumeMountWatcherWin() override;
  26. static bool GetDeviceRemovable(const base::FilePath& device_path,
  27. bool* removable);
  28. void AddDeviceForTesting(const base::FilePath& device_path,
  29. const std::string& device_id,
  30. const std::u16string& device_name,
  31. uint64_t total_size_in_bytes);
  32. void SetAttachedDevicesFake();
  33. const std::vector<base::FilePath>& devices_checked() const {
  34. return devices_checked_;
  35. }
  36. void BlockDeviceCheckForTesting();
  37. void ReleaseDeviceCheck();
  38. // VolumeMountWatcherWin:
  39. void DeviceCheckComplete(const base::FilePath& device_path) override;
  40. GetAttachedDevicesCallbackType GetAttachedDevicesCallback() const override;
  41. GetDeviceDetailsCallbackType GetDeviceDetailsCallback() const override;
  42. private:
  43. std::vector<base::FilePath> devices_checked_;
  44. std::unique_ptr<base::WaitableEvent> device_check_complete_event_;
  45. bool attached_devices_fake_;
  46. };
  47. } // namespace storage_monitor
  48. #endif // COMPONENTS_STORAGE_MONITOR_TEST_VOLUME_MOUNT_WATCHER_WIN_H_