15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// This file contains a subclass of PortableDeviceWatcherWin to expose some
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// functionality for testing.
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string>
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string16.h"
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/storage_monitor/portable_device_watcher_win.h"
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace storage_monitor {
17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class TestPortableDeviceWatcherWin : public PortableDeviceWatcherWin {
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // MTP device PnP identifiers.
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static const base::char16 kMTPDeviceWithMultipleStorages[];
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static const base::char16 kMTPDeviceWithInvalidInfo[];
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  static const base::char16 kMTPDeviceWithValidInfo[];
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // MTP device storage unique identifier.
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static const char kStorageUniqueIdA[];
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  TestPortableDeviceWatcherWin();
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~TestPortableDeviceWatcherWin();
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns the persistent storage unique id of the device specified by the
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |pnp_device_id|. |storage_object_id| specifies the string ID that uniquely
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // identifies the object on the device.
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  static std::string GetMTPStorageUniqueId(
35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& pnp_device_id,
36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& storage_object_id);
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns a list of storage object identifiers of the media transfer protocol
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // (MTP) device given a |pnp_device_id|.
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static PortableDeviceWatcherWin::StorageObjectIDs GetMTPStorageObjectIds(
41a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& pnp_device_id);
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Gets the media transfer protocol (MTP) device storage details given a
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |pnp_device_id| and |storage_object_id|.
45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  static void GetMTPStorageDetails(const base::string16& pnp_device_id,
46a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                   const base::string16& storage_object_id,
47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                   base::string16* device_location,
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                   std::string* unique_id,
49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)                                   base::string16* name);
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns a list of device storage details for the given device specified by
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |pnp_device_id|.
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static PortableDeviceWatcherWin::StorageObjects GetDeviceStorageObjects(
54a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& pnp_device_id);
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Used by MediaFileSystemRegistry unit test.
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void set_use_dummy_mtp_storage_info(bool use_dummy_info) {
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    use_dummy_mtp_storage_info_ = use_dummy_info;
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // PortableDeviceWatcherWin:
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void EnumerateAttachedDevices() OVERRIDE;
64a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void HandleDeviceAttachEvent(
65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      const base::string16& pnp_device_id) OVERRIDE;
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual bool GetMTPStorageInfoFromDeviceId(
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const std::string& storage_device_id,
68a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      base::string16* device_location,
69a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      base::string16* storage_object_id) const OVERRIDE;
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Set to true to get dummy storage details from
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // GetMTPStorageInfoFromDeviceId().
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool use_dummy_mtp_storage_info_;
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(TestPortableDeviceWatcherWin);
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
78a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}  // namespace storage_monitor
79a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif  // COMPONENTS_STORAGE_MONITOR_TEST_PORTABLE_DEVICE_WATCHER_WIN_H_
81