OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/bluetooth/bluetooth_type_converters.h" | 5 #include "components/arc/bluetooth/bluetooth_type_converters.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 EXPECT_EQ(std::string(kInvalidAddressStr), addressMojo->To<std::string>()); | 107 EXPECT_EQ(std::string(kInvalidAddressStr), addressMojo->To<std::string>()); |
108 } | 108 } |
109 | 109 |
110 | 110 |
111 TEST(BluetoothTypeConvertorTest, ConvertMojoValueAttributeToBlueZAttribute) { | 111 TEST(BluetoothTypeConvertorTest, ConvertMojoValueAttributeToBlueZAttribute) { |
112 // Construct Mojo attribute with NULLTYPE value. | 112 // Construct Mojo attribute with NULLTYPE value. |
113 auto nulltypeAttributeMojo = arc::mojom::BluetoothSdpAttribute::New(); | 113 auto nulltypeAttributeMojo = arc::mojom::BluetoothSdpAttribute::New(); |
114 nulltypeAttributeMojo->type = | 114 nulltypeAttributeMojo->type = |
115 bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE; | 115 bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE; |
116 nulltypeAttributeMojo->type_size = 0; | 116 nulltypeAttributeMojo->type_size = 0; |
117 nulltypeAttributeMojo->value.Append(base::Value::CreateNullValue()); | 117 nulltypeAttributeMojo->value.Append(base::MakeUnique<base::Value>()); |
118 | 118 |
119 auto nulltypeAttributeBlueZ = | 119 auto nulltypeAttributeBlueZ = |
120 nulltypeAttributeMojo.To<bluez::BluetoothServiceAttributeValueBlueZ>(); | 120 nulltypeAttributeMojo.To<bluez::BluetoothServiceAttributeValueBlueZ>(); |
121 | 121 |
122 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, | 122 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, |
123 nulltypeAttributeBlueZ.type()); | 123 nulltypeAttributeBlueZ.type()); |
124 EXPECT_EQ(0u, nulltypeAttributeBlueZ.size()); | 124 EXPECT_EQ(0u, nulltypeAttributeBlueZ.size()); |
125 EXPECT_EQ(base::Value::Type::NONE, nulltypeAttributeBlueZ.value().GetType()); | 125 EXPECT_EQ(base::Value::Type::NONE, nulltypeAttributeBlueZ.value().GetType()); |
126 | 126 |
127 // Construct Mojo attribute with TYPE_BOOLEAN value. | 127 // Construct Mojo attribute with TYPE_BOOLEAN value. |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 EXPECT_EQ(0u, valueNoDataBlueZ.size()); | 280 EXPECT_EQ(0u, valueNoDataBlueZ.size()); |
281 EXPECT_EQ(base::Value::Type::NONE, valueNoDataBlueZ.value().GetType()); | 281 EXPECT_EQ(base::Value::Type::NONE, valueNoDataBlueZ.value().GetType()); |
282 } | 282 } |
283 | 283 |
284 TEST(BluetoothTypeConvertorTest, | 284 TEST(BluetoothTypeConvertorTest, |
285 ConvertInvalidMojoSequenceAttributeToBlueZAttribute) { | 285 ConvertInvalidMojoSequenceAttributeToBlueZAttribute) { |
286 // Create a Mojo attribute with an empty sequence. | 286 // Create a Mojo attribute with an empty sequence. |
287 auto sequenceNoData = arc::mojom::BluetoothSdpAttribute::New(); | 287 auto sequenceNoData = arc::mojom::BluetoothSdpAttribute::New(); |
288 sequenceNoData->type = bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE; | 288 sequenceNoData->type = bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE; |
289 sequenceNoData->type_size = 0; | 289 sequenceNoData->type_size = 0; |
290 sequenceNoData->value.Append(base::Value::CreateNullValue()); | 290 sequenceNoData->value.Append(base::MakeUnique<base::Value>()); |
291 | 291 |
292 auto sequenceNoDataBlueZ = | 292 auto sequenceNoDataBlueZ = |
293 sequenceNoData.To<bluez::BluetoothServiceAttributeValueBlueZ>(); | 293 sequenceNoData.To<bluez::BluetoothServiceAttributeValueBlueZ>(); |
294 | 294 |
295 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, | 295 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, |
296 sequenceNoDataBlueZ.type()); | 296 sequenceNoDataBlueZ.type()); |
297 EXPECT_EQ(0u, sequenceNoDataBlueZ.size()); | 297 EXPECT_EQ(0u, sequenceNoDataBlueZ.size()); |
298 EXPECT_EQ(base::Value::Type::NONE, sequenceNoDataBlueZ.value().GetType()); | 298 EXPECT_EQ(base::Value::Type::NONE, sequenceNoDataBlueZ.value().GetType()); |
299 | 299 |
300 // Create a Mojo attribute with the depth = arc::kBluetoothSDPMaxDepth + 3. | 300 // Create a Mojo attribute with the depth = arc::kBluetoothSDPMaxDepth + 3. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 auto sequenceMojo = | 444 auto sequenceMojo = |
445 ConvertTo<arc::mojom::BluetoothSdpAttributePtr>(sequenceBlueZ); | 445 ConvertTo<arc::mojom::BluetoothSdpAttributePtr>(sequenceBlueZ); |
446 | 446 |
447 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE, | 447 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE, |
448 sequenceMojo->type); | 448 sequenceMojo->type); |
449 EXPECT_EQ((uint32_t)1, sequenceMojo->type_size); | 449 EXPECT_EQ((uint32_t)1, sequenceMojo->type_size); |
450 EXPECT_EQ(arc::kBluetoothSDPMaxDepth, GetDepthOfMojoAttribute(sequenceMojo)); | 450 EXPECT_EQ(arc::kBluetoothSDPMaxDepth, GetDepthOfMojoAttribute(sequenceMojo)); |
451 } | 451 } |
452 | 452 |
453 } // namespace mojo | 453 } // namespace mojo |
OLD | NEW |