Index: components/arc/bluetooth/bluetooth_type_converters_unittest.cc |
diff --git a/components/arc/bluetooth/bluetooth_type_converters_unittest.cc b/components/arc/bluetooth/bluetooth_type_converters_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..63677a66af657491f45d4eb7cbec8742425329a0 |
--- /dev/null |
+++ b/components/arc/bluetooth/bluetooth_type_converters_unittest.cc |
@@ -0,0 +1,73 @@ |
+// Copyright 2016 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 "components/arc/bluetooth/bluetooth_type_converters.h" |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "device/bluetooth/bluetooth_gatt_service.h" |
+#include "device/bluetooth/bluetooth_uuid.h" |
+#include "mojo/public/cpp/bindings/array.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace mojo { |
+ |
+TEST(BluetoothTypeConvertorTest, ConvertMojoBluetoothAddressFromString) { |
+ const std::string kAddressStr = "1A:2B:3C:4D:5E:6F"; |
+ const uint8_t kAddressArray[] = {0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f}; |
+ const size_t kAddressSize = 6; |
+ |
+ arc::mojom::BluetoothAddressPtr addressMojo = |
+ arc::mojom::BluetoothAddress::From(kAddressStr); |
+ EXPECT_EQ(kAddressSize, addressMojo->address.size()); |
+ for (size_t i = 0; i < kAddressSize; i++) { |
+ EXPECT_EQ(kAddressArray[i], addressMojo->address[i]); |
+ } |
+} |
+ |
+TEST(BluetoothTypeConvertorTest, ConvertMojoBluetoothAddressToString) { |
+ const std::string kAddressStr = "1A:2B:3C:4D:5E:6F"; |
+ const uint8_t kAddressArray[] = {0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f}; |
+ const size_t kAddressSize = 6; |
+ |
+ arc::mojom::BluetoothAddressPtr addressMojo = |
+ arc::mojom::BluetoothAddress::New(); |
+ for (size_t i = 0; i < kAddressSize; i++) { |
+ addressMojo->address.push_back(kAddressArray[i]); |
+ } |
+ EXPECT_EQ(kAddressStr, addressMojo->To<std::string>()); |
+} |
+ |
+TEST(BluetoothTypeConvertorTest, |
+ ConvertMojoBluetoothUUIDFromDeviceBluetoothUUID) { |
+ const std::string kUuidStr = "12345678-1234-5678-9abc-def123456789"; |
+ const uint8_t kUuidArray[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, |
+ 0x9a, 0xbc, 0xde, 0xf1, 0x23, 0x45, 0x67, 0x89}; |
+ const size_t kUuidSize = 16; |
+ |
+ device::BluetoothUUID uuidDevice(kUuidStr); |
+ arc::mojom::BluetoothUUIDPtr uuidMojo = |
+ arc::mojom::BluetoothUUID::From(uuidDevice); |
+ EXPECT_EQ(kUuidSize, uuidMojo->uuid.size()); |
+ for (size_t i = 0; i < kUuidSize; i++) { |
+ EXPECT_EQ(kUuidArray[i], uuidMojo->uuid[i]); |
+ } |
+} |
+ |
+TEST(BluetoothTypeConvertorTest, |
+ ConvertMojoBluetoothUUIDToDeviceBluetoothUUID) { |
+ const std::string kUuidStr = "12345678-1234-5678-9abc-def123456789"; |
+ const uint8_t kUuidArray[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, |
+ 0x9a, 0xbc, 0xde, 0xf1, 0x23, 0x45, 0x67, 0x89}; |
+ const size_t kUuidSize = 16; |
+ |
+ arc::mojom::BluetoothUUIDPtr uuidMojo = arc::mojom::BluetoothUUID::New(); |
+ for (size_t i = 0; i < kUuidSize; i++) { |
+ uuidMojo->uuid.push_back(kUuidArray[i]); |
+ } |
+ EXPECT_EQ(kUuidStr, uuidMojo.To<device::BluetoothUUID>().canonical_value()); |
+} |
+ |
+} // namespace mojo |