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.
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_
13 #include "base/strings/string16.h"
14 #include "components/storage_monitor/portable_device_watcher_win.h"
16 class TestPortableDeviceWatcherWin : public PortableDeviceWatcherWin {
18 // MTP device PnP identifiers.
19 static const base::char16 kMTPDeviceWithMultipleStorages[];
20 static const base::char16 kMTPDeviceWithInvalidInfo[];
21 static const base::char16 kMTPDeviceWithValidInfo[];
23 // MTP device storage unique identifier.
24 static const char kStorageUniqueIdA[];
26 TestPortableDeviceWatcherWin();
27 virtual ~TestPortableDeviceWatcherWin();
29 // Returns the persistent storage unique id of the device specified by the
30 // |pnp_device_id|. |storage_object_id| specifies the string ID that uniquely
31 // identifies the object on the device.
32 static std::string GetMTPStorageUniqueId(
33 const base::string16& pnp_device_id,
34 const base::string16& storage_object_id);
36 // Returns a list of storage object identifiers of the media transfer protocol
37 // (MTP) device given a |pnp_device_id|.
38 static PortableDeviceWatcherWin::StorageObjectIDs GetMTPStorageObjectIds(
39 const base::string16& pnp_device_id);
41 // Gets the media transfer protocol (MTP) device storage details given a
42 // |pnp_device_id| and |storage_object_id|.
43 static void GetMTPStorageDetails(const base::string16& pnp_device_id,
44 const base::string16& storage_object_id,
45 base::string16* device_location,
46 std::string* unique_id,
47 base::string16* name);
49 // Returns a list of device storage details for the given device specified by
51 static PortableDeviceWatcherWin::StorageObjects GetDeviceStorageObjects(
52 const base::string16& pnp_device_id);
54 // Used by MediaFileSystemRegistry unit test.
55 void set_use_dummy_mtp_storage_info(bool use_dummy_info) {
56 use_dummy_mtp_storage_info_ = use_dummy_info;
60 // PortableDeviceWatcherWin:
61 virtual void EnumerateAttachedDevices() OVERRIDE;
62 virtual void HandleDeviceAttachEvent(
63 const base::string16& pnp_device_id) OVERRIDE;
64 virtual bool GetMTPStorageInfoFromDeviceId(
65 const std::string& storage_device_id,
66 base::string16* device_location,
67 base::string16* storage_object_id) const OVERRIDE;
69 // Set to true to get dummy storage details from
70 // GetMTPStorageInfoFromDeviceId().
71 bool use_dummy_mtp_storage_info_;
73 DISALLOW_COPY_AND_ASSIGN(TestPortableDeviceWatcherWin);
76 #endif // COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_