Roll src/third_party/WebKit 2146135:dc7c4b0 (svn 202183:202185)
[chromium-blink-merge.git] / components / storage_monitor / storage_info_unittest.cc
blobe9ef3784c2b37aa29e4a87effa8ee46e298618cb
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.
5 #include <string>
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
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);
34 TEST(StorageInfoTest, TestImageCaptureDeviceId) {
35 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);
42 } // namespace storage_monitor