Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / components / storage_monitor / test_portable_device_watcher_win.h
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.
7
8 #ifndef COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_
9 #define COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_
10
11 #include <string>
12
13 #include "base/strings/string16.h"
14 #include "components/storage_monitor/portable_device_watcher_win.h"
15
16 class TestPortableDeviceWatcherWin : public PortableDeviceWatcherWin {
17  public:
18   // MTP device PnP identifiers.
19   static const base::char16 kMTPDeviceWithMultipleStorages[];
20   static const base::char16 kMTPDeviceWithInvalidInfo[];
21   static const base::char16 kMTPDeviceWithValidInfo[];
22
23   // MTP device storage unique identifier.
24   static const char kStorageUniqueIdA[];
25
26   TestPortableDeviceWatcherWin();
27   virtual ~TestPortableDeviceWatcherWin();
28
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);
35
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);
40
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);
48
49   // Returns a list of device storage details for the given device specified by
50   // |pnp_device_id|.
51   static PortableDeviceWatcherWin::StorageObjects GetDeviceStorageObjects(
52       const base::string16& pnp_device_id);
53
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;
57   }
58
59  private:
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;
68
69   // Set to true to get dummy storage details from
70   // GetMTPStorageInfoFromDeviceId().
71   bool use_dummy_mtp_storage_info_;
72
73   DISALLOW_COPY_AND_ASSIGN(TestPortableDeviceWatcherWin);
74 };
75
76 #endif  // COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_