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.
7 #include "components/storage_monitor/storage_info.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace storage_monitor
{
12 const char kMtpDeviceId
[] = "mtp:VendorModelSerial:ABC:1233:1237912873";
13 const char kUniqueId
[] = "VendorModelSerial:ABC:1233:1237912873";
14 const char kImageCaptureDeviceId
[] = "ic:xyz";
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
);
24 // Test to verify |CrackDeviceId| functionality using a sample
26 TEST(StorageInfoTest
, CrackMtpDeviceId
) {
27 StorageInfo::Type type
;
29 ASSERT_TRUE(StorageInfo::CrackDeviceId(kMtpDeviceId
, &type
, &id
));
30 EXPECT_EQ(kUniqueId
, id
);
31 EXPECT_EQ(StorageInfo::MTP_OR_PTP
, type
);
34 TEST(StorageInfoTest
, TestImageCaptureDeviceId
) {
35 StorageInfo::Type type
;
37 ASSERT_TRUE(StorageInfo::CrackDeviceId(kImageCaptureDeviceId
, &type
, &id
));
38 EXPECT_EQ(StorageInfo::MAC_IMAGE_CAPTURE
, type
);
42 } // namespace storage_monitor