OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "chrome/browser/storage_monitor/storage_info.h" | 7 #include "chrome/browser/storage_monitor/storage_info.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 const char kMtpDeviceId[] = "mtp:VendorModelSerial:ABC:1233:1237912873"; | 10 const char kMtpDeviceId[] = "mtp:VendorModelSerial:ABC:1233:1237912873"; |
11 const char kUniqueId[] = "VendorModelSerial:ABC:1233:1237912873"; | 11 const char kUniqueId[] = "VendorModelSerial:ABC:1233:1237912873"; |
12 const char kImageCaptureDeviceId[] = "ic:xyz"; | 12 const char kImageCaptureDeviceId[] = "ic:xyz"; |
13 | 13 |
14 namespace chrome { | |
15 | |
16 // Test to verify |MakeDeviceId| functionality using a sample | 14 // Test to verify |MakeDeviceId| functionality using a sample |
17 // mtp device unique id. | 15 // mtp device unique id. |
18 TEST(StorageInfoTest, MakeMtpDeviceId) { | 16 TEST(StorageInfoTest, MakeMtpDeviceId) { |
19 std::string device_id = | 17 std::string device_id = |
20 StorageInfo::MakeDeviceId(StorageInfo::MTP_OR_PTP, kUniqueId); | 18 StorageInfo::MakeDeviceId(StorageInfo::MTP_OR_PTP, kUniqueId); |
21 ASSERT_EQ(kMtpDeviceId, device_id); | 19 ASSERT_EQ(kMtpDeviceId, device_id); |
22 } | 20 } |
23 | 21 |
24 // Test to verify |CrackDeviceId| functionality using a sample | 22 // Test to verify |CrackDeviceId| functionality using a sample |
25 // mtp device id. | 23 // mtp device id. |
26 TEST(StorageInfoTest, CrackMtpDeviceId) { | 24 TEST(StorageInfoTest, CrackMtpDeviceId) { |
27 StorageInfo::Type type; | 25 StorageInfo::Type type; |
28 std::string id; | 26 std::string id; |
29 ASSERT_TRUE(StorageInfo::CrackDeviceId(kMtpDeviceId, &type, &id)); | 27 ASSERT_TRUE(StorageInfo::CrackDeviceId(kMtpDeviceId, &type, &id)); |
30 EXPECT_EQ(kUniqueId, id); | 28 EXPECT_EQ(kUniqueId, id); |
31 EXPECT_EQ(StorageInfo::MTP_OR_PTP, type); | 29 EXPECT_EQ(StorageInfo::MTP_OR_PTP, type); |
32 } | 30 } |
33 | 31 |
34 TEST(StorageInfoTest, TestImageCaptureDeviceId) { | 32 TEST(StorageInfoTest, TestImageCaptureDeviceId) { |
35 chrome::StorageInfo::Type type; | 33 StorageInfo::Type type; |
36 std::string id; | 34 std::string id; |
37 ASSERT_TRUE(StorageInfo::CrackDeviceId(kImageCaptureDeviceId, &type, &id)); | 35 ASSERT_TRUE(StorageInfo::CrackDeviceId(kImageCaptureDeviceId, &type, &id)); |
38 EXPECT_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type); | 36 EXPECT_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type); |
39 EXPECT_EQ("xyz", id); | 37 EXPECT_EQ("xyz", id); |
40 } | 38 } |
41 | |
42 } // namespace chrome | |
OLD | NEW |