storage_info_unittest.cc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include <string>
  5. #include "components/storage_monitor/storage_info.h"
  6. #include "testing/gtest/include/gtest/gtest.h"
  7. namespace storage_monitor {
  8. const char kMtpDeviceId[] = "mtp:VendorModelSerial:ABC:1233:1237912873";
  9. const char kUniqueId[] = "VendorModelSerial:ABC:1233:1237912873";
  10. const char kImageCaptureDeviceId[] = "ic:xyz";
  11. // Test to verify |MakeDeviceId| functionality using a sample
  12. // mtp device unique id.
  13. TEST(StorageInfoTest, MakeMtpDeviceId) {
  14. std::string device_id =
  15. StorageInfo::MakeDeviceId(StorageInfo::MTP_OR_PTP, kUniqueId);
  16. ASSERT_EQ(kMtpDeviceId, device_id);
  17. }
  18. // Test to verify |CrackDeviceId| functionality using a sample
  19. // mtp device id.
  20. TEST(StorageInfoTest, CrackMtpDeviceId) {
  21. StorageInfo::Type type;
  22. std::string id;
  23. ASSERT_TRUE(StorageInfo::CrackDeviceId(kMtpDeviceId, &type, &id));
  24. EXPECT_EQ(kUniqueId, id);
  25. EXPECT_EQ(StorageInfo::MTP_OR_PTP, type);
  26. }
  27. TEST(StorageInfoTest, TestImageCaptureDeviceId) {
  28. StorageInfo::Type type;
  29. std::string id;
  30. ASSERT_TRUE(StorageInfo::CrackDeviceId(kImageCaptureDeviceId, &type, &id));
  31. EXPECT_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type);
  32. EXPECT_EQ("xyz", id);
  33. }
  34. } // namespace storage_monitor