Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / components / storage_monitor / storage_info_unittest.cc
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
5 #include <string>
6
7 #include "components/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 // Test to verify |MakeDeviceId| functionality using a sample
15 // mtp device unique id.
16 TEST(StorageInfoTest, MakeMtpDeviceId) {
17   std::string device_id =
18       StorageInfo::MakeDeviceId(StorageInfo::MTP_OR_PTP, kUniqueId);
19   ASSERT_EQ(kMtpDeviceId, device_id);
20 }
21
22 // Test to verify |CrackDeviceId| functionality using a sample
23 // mtp device id.
24 TEST(StorageInfoTest, CrackMtpDeviceId) {
25   StorageInfo::Type type;
26   std::string id;
27   ASSERT_TRUE(StorageInfo::CrackDeviceId(kMtpDeviceId, &type, &id));
28   EXPECT_EQ(kUniqueId, id);
29   EXPECT_EQ(StorageInfo::MTP_OR_PTP, type);
30 }
31
32 TEST(StorageInfoTest, TestImageCaptureDeviceId) {
33   StorageInfo::Type type;
34   std::string id;
35   ASSERT_TRUE(StorageInfo::CrackDeviceId(kImageCaptureDeviceId, &type, &id));
36   EXPECT_EQ(StorageInfo::MAC_IMAGE_CAPTURE, type);
37   EXPECT_EQ("xyz", id);
38 }