Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: components/arc/bluetooth/bluetooth_type_converters_unittest.cc

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698