Index: chrome/browser/media_gallery/media_storage_util_unittest.cc |
diff --git a/chrome/browser/media_gallery/media_storage_util_unittest.cc b/chrome/browser/media_gallery/media_storage_util_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..54927e5c71d3ec000db2432c1dcc4f9f9676131b |
--- /dev/null |
+++ b/chrome/browser/media_gallery/media_storage_util_unittest.cc |
@@ -0,0 +1,42 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <string> |
+ |
+#include "chrome/browser/media_gallery/media_storage_util.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace chrome { |
+ |
+namespace { |
+ |
+// Sample mtp device id and unique id. |
+const char kMtpDeviceId[] = "mtp:VendorModelSerial:ABC:1233:1237912873"; |
+const char kUniqueId[] = "VendorModelSerial:ABC:1233:1237912873"; |
+ |
+} // namespace |
+ |
+// Class to test |MediaStorageUtil| functions. |
+class MediaStorageUtilTest : public testing::Test { |
Lei Zhang
2012/08/27 18:57:50
Since this is an empty class, just do:
typedef tes
kmadhusu
2012/08/27 20:25:46
Done.
|
+}; |
+ |
+// Test to verify |MediaStorageUtil::MakeDeviceId| functionality using a sample |
+// mtp device unique id. |
+TEST_F(MediaStorageUtilTest, MakeMtpDeviceId) { |
+ std::string device_id = |
+ MediaStorageUtil::MakeDeviceId(MediaStorageUtil::USB_MTP, kUniqueId); |
+ ASSERT_EQ(device_id, kMtpDeviceId); |
Lei Zhang
2012/08/27 18:57:50
All the ASSERT_EQ()s in this file should have thei
kmadhusu
2012/08/27 20:25:46
Done.
|
+} |
+ |
+// Test to verify |MediaStorageUtil::CrackDeviceId| functionality using a sample |
+// mtp device id. |
+TEST_F(MediaStorageUtilTest, CrackMtpDeviceId) { |
+ MediaStorageUtil::Type type; |
+ std::string id; |
+ ASSERT_TRUE(MediaStorageUtil::CrackDeviceId(kMtpDeviceId, &type, &id)); |
+ ASSERT_EQ(id, kUniqueId); |
+ ASSERT_EQ(type, MediaStorageUtil::USB_MTP); |
+} |
+ |
+} // namespace chrome |