| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 EXPECT_EQ(static_cast<uint32_t>(sizeof(valueBool)), | 355 EXPECT_EQ(static_cast<uint32_t>(sizeof(valueBool)), |
| 356 boolAttributeMojo->type_size); | 356 boolAttributeMojo->type_size); |
| 357 EXPECT_TRUE(boolAttributeMojo->value.GetBoolean(0, &actualBool)); | 357 EXPECT_TRUE(boolAttributeMojo->value.GetBoolean(0, &actualBool)); |
| 358 EXPECT_FALSE(valueBool); | 358 EXPECT_FALSE(valueBool); |
| 359 | 359 |
| 360 // Check UUID type. | 360 // Check UUID type. |
| 361 std::string valueUUID("00000100-0000-1000-8000-00805f9b34fb"); | 361 std::string valueUUID("00000100-0000-1000-8000-00805f9b34fb"); |
| 362 std::string actualUUID; | 362 std::string actualUUID; |
| 363 auto uuidAttributeBlueZ = bluez::BluetoothServiceAttributeValueBlueZ( | 363 auto uuidAttributeBlueZ = bluez::BluetoothServiceAttributeValueBlueZ( |
| 364 bluez::BluetoothServiceAttributeValueBlueZ::UUID, sizeof(uint16_t), | 364 bluez::BluetoothServiceAttributeValueBlueZ::UUID, sizeof(uint16_t), |
| 365 base::MakeUnique<base::StringValue>(valueUUID)); | 365 base::MakeUnique<base::Value>(valueUUID)); |
| 366 | 366 |
| 367 auto uuidAttributeMojo = | 367 auto uuidAttributeMojo = |
| 368 ConvertTo<arc::mojom::BluetoothSdpAttributePtr>(uuidAttributeBlueZ); | 368 ConvertTo<arc::mojom::BluetoothSdpAttributePtr>(uuidAttributeBlueZ); |
| 369 | 369 |
| 370 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::UUID, | 370 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::UUID, |
| 371 uuidAttributeMojo->type); | 371 uuidAttributeMojo->type); |
| 372 EXPECT_EQ(static_cast<uint32_t>(sizeof(uint16_t)), | 372 EXPECT_EQ(static_cast<uint32_t>(sizeof(uint16_t)), |
| 373 uuidAttributeMojo->type_size); | 373 uuidAttributeMojo->type_size); |
| 374 EXPECT_TRUE(uuidAttributeMojo->value.GetString(0, &actualUUID)); | 374 EXPECT_TRUE(uuidAttributeMojo->value.GetString(0, &actualUUID)); |
| 375 EXPECT_EQ(valueUUID, actualUUID); | 375 EXPECT_EQ(valueUUID, actualUUID); |
| 376 | 376 |
| 377 // Check string types (STRING, URL). | 377 // Check string types (STRING, URL). |
| 378 std::string valueString("Some Service Name"); | 378 std::string valueString("Some Service Name"); |
| 379 std::string actualString; | 379 std::string actualString; |
| 380 auto stringAttributeBlueZ = bluez::BluetoothServiceAttributeValueBlueZ( | 380 auto stringAttributeBlueZ = bluez::BluetoothServiceAttributeValueBlueZ( |
| 381 bluez::BluetoothServiceAttributeValueBlueZ::STRING, valueString.length(), | 381 bluez::BluetoothServiceAttributeValueBlueZ::STRING, valueString.length(), |
| 382 base::MakeUnique<base::StringValue>(valueString)); | 382 base::MakeUnique<base::Value>(valueString)); |
| 383 | 383 |
| 384 auto stringAttributeMojo = | 384 auto stringAttributeMojo = |
| 385 ConvertTo<arc::mojom::BluetoothSdpAttributePtr>(stringAttributeBlueZ); | 385 ConvertTo<arc::mojom::BluetoothSdpAttributePtr>(stringAttributeBlueZ); |
| 386 | 386 |
| 387 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::STRING, | 387 EXPECT_EQ(bluez::BluetoothServiceAttributeValueBlueZ::STRING, |
| 388 stringAttributeMojo->type); | 388 stringAttributeMojo->type); |
| 389 EXPECT_EQ(static_cast<uint32_t>(valueString.length()), | 389 EXPECT_EQ(static_cast<uint32_t>(valueString.length()), |
| 390 stringAttributeMojo->type_size); | 390 stringAttributeMojo->type_size); |
| 391 EXPECT_TRUE(stringAttributeMojo->value.GetString(0, &actualString)); | 391 EXPECT_TRUE(stringAttributeMojo->value.GetString(0, &actualString)); |
| 392 EXPECT_EQ(valueString, actualString); | 392 EXPECT_EQ(valueString, actualString); |
| 393 } | 393 } |
| 394 | 394 |
| 395 TEST(BluetoothTypeConvertorTest, ConvertBlueZSequenceAttributeToMojoAttribute) { | 395 TEST(BluetoothTypeConvertorTest, ConvertBlueZSequenceAttributeToMojoAttribute) { |
| 396 std::string l2capUUID("00000100-0000-1000-8000-00805f9b34fb"); | 396 std::string l2capUUID("00000100-0000-1000-8000-00805f9b34fb"); |
| 397 uint16_t l2capChannel = 3; | 397 uint16_t l2capChannel = 3; |
| 398 | 398 |
| 399 std::unique_ptr<bluez::BluetoothServiceAttributeValueBlueZ::Sequence> | 399 std::unique_ptr<bluez::BluetoothServiceAttributeValueBlueZ::Sequence> |
| 400 sequence(new bluez::BluetoothServiceAttributeValueBlueZ::Sequence()); | 400 sequence(new bluez::BluetoothServiceAttributeValueBlueZ::Sequence()); |
| 401 sequence->push_back(bluez::BluetoothServiceAttributeValueBlueZ( | 401 sequence->push_back(bluez::BluetoothServiceAttributeValueBlueZ( |
| 402 bluez::BluetoothServiceAttributeValueBlueZ::UUID, sizeof(uint16_t), | 402 bluez::BluetoothServiceAttributeValueBlueZ::UUID, sizeof(uint16_t), |
| 403 base::MakeUnique<base::StringValue>(l2capUUID))); | 403 base::MakeUnique<base::Value>(l2capUUID))); |
| 404 sequence->push_back(bluez::BluetoothServiceAttributeValueBlueZ( | 404 sequence->push_back(bluez::BluetoothServiceAttributeValueBlueZ( |
| 405 bluez::BluetoothServiceAttributeValueBlueZ::UINT, sizeof(uint16_t), | 405 bluez::BluetoothServiceAttributeValueBlueZ::UINT, sizeof(uint16_t), |
| 406 base::MakeUnique<base::Value>(l2capChannel))); | 406 base::MakeUnique<base::Value>(l2capChannel))); |
| 407 | 407 |
| 408 auto sequenceBlueZ = | 408 auto sequenceBlueZ = |
| 409 bluez::BluetoothServiceAttributeValueBlueZ(std::move(sequence)); | 409 bluez::BluetoothServiceAttributeValueBlueZ(std::move(sequence)); |
| 410 | 410 |
| 411 ASSERT_EQ(2u, sequenceBlueZ.sequence().size()); | 411 ASSERT_EQ(2u, sequenceBlueZ.sequence().size()); |
| 412 | 412 |
| 413 auto sequenceMojo = | 413 auto sequenceMojo = |
| (...skipping 30 matching lines...) Expand all 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 |