Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / components / storage_monitor / test_portable_device_watcher_win.h
blobbc108b1afcec69b4b5505cb9b4d412d5cabd0b8e
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 PortableDeviceWatcherWin to expose some
6 // functionality for testing.
8 #ifndef COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_
9 #define COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_
11 #include <string>
13 #include "base/strings/string16.h"
14 #include "components/storage_monitor/portable_device_watcher_win.h"
16 namespace storage_monitor {
18 class TestPortableDeviceWatcherWin : public PortableDeviceWatcherWin {
19 public:
20 // MTP device PnP identifiers.
21 static const base::char16 kMTPDeviceWithMultipleStorages[];
22 static const base::char16 kMTPDeviceWithInvalidInfo[];
23 static const base::char16 kMTPDeviceWithValidInfo[];
25 // MTP device storage unique identifier.
26 static const char kStorageUniqueIdA[];
28 TestPortableDeviceWatcherWin();
29 virtual ~TestPortableDeviceWatcherWin();
31 // Returns the persistent storage unique id of the device specified by the
32 // |pnp_device_id|. |storage_object_id| specifies the string ID that uniquely
33 // identifies the object on the device.
34 static std::string GetMTPStorageUniqueId(
35 const base::string16& pnp_device_id,
36 const base::string16& storage_object_id);
38 // Returns a list of storage object identifiers of the media transfer protocol
39 // (MTP) device given a |pnp_device_id|.
40 static PortableDeviceWatcherWin::StorageObjectIDs GetMTPStorageObjectIds(
41 const base::string16& pnp_device_id);
43 // Gets the media transfer protocol (MTP) device storage details given a
44 // |pnp_device_id| and |storage_object_id|.
45 static void GetMTPStorageDetails(const base::string16& pnp_device_id,
46 const base::string16& storage_object_id,
47 base::string16* device_location,
48 std::string* unique_id,
49 base::string16* name);
51 // Returns a list of device storage details for the given device specified by
52 // |pnp_device_id|.
53 static PortableDeviceWatcherWin::StorageObjects GetDeviceStorageObjects(
54 const base::string16& pnp_device_id);
56 // Used by MediaFileSystemRegistry unit test.
57 void set_use_dummy_mtp_storage_info(bool use_dummy_info) {
58 use_dummy_mtp_storage_info_ = use_dummy_info;
61 private:
62 // PortableDeviceWatcherWin:
63 virtual void EnumerateAttachedDevices() override;
64 virtual void HandleDeviceAttachEvent(
65 const base::string16& pnp_device_id) override;
66 virtual bool GetMTPStorageInfoFromDeviceId(
67 const std::string& storage_device_id,
68 base::string16* device_location,
69 base::string16* storage_object_id) const override;
71 // Set to true to get dummy storage details from
72 // GetMTPStorageInfoFromDeviceId().
73 bool use_dummy_mtp_storage_info_;
75 DISALLOW_COPY_AND_ASSIGN(TestPortableDeviceWatcherWin);
78 } // namespace storage_monitor
80 #endif // COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_