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