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

Side by Side Diff: device/bluetooth/bluez/bluetooth_service_attribute_value_bluez_unittest.cc

Issue 2476493003: Remove FundamentalValue
Patch Set: Fix Created 4 years, 1 month 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
« no previous file with comments | « dbus/values_util_unittest.cc ('k') | device/bluetooth/dbus/bluetooth_device_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h" 5 #include "device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 Type::UUID, 16, base::MakeUnique<base::StringValue>(kServiceUuid)); 51 Type::UUID, 16, base::MakeUnique<base::StringValue>(kServiceUuid));
52 BluetoothServiceAttributeValueBlueZ value2 = value1; 52 BluetoothServiceAttributeValueBlueZ value2 = value1;
53 53
54 CheckUuidValue(value2, kServiceUuid); 54 CheckUuidValue(value2, kServiceUuid);
55 } 55 }
56 56
57 TEST(BluetoothServiceAttributeBlueZTest, Sequence) { 57 TEST(BluetoothServiceAttributeBlueZTest, Sequence) {
58 BluetoothServiceAttributeValueBlueZ value1( 58 BluetoothServiceAttributeValueBlueZ value1(
59 Type::UUID, 16, base::MakeUnique<base::StringValue>(kServiceUuid)); 59 Type::UUID, 16, base::MakeUnique<base::StringValue>(kServiceUuid));
60 BluetoothServiceAttributeValueBlueZ value2( 60 BluetoothServiceAttributeValueBlueZ value2(
61 Type::INT, 4, base::MakeUnique<base::FundamentalValue>(0x1337)); 61 Type::INT, 4, base::MakeUnique<base::Value>(0x1337));
62 BluetoothServiceAttributeValueBlueZ value3( 62 BluetoothServiceAttributeValueBlueZ value3(
63 Type::INT, 4, base::MakeUnique<base::FundamentalValue>(0x7331)); 63 Type::INT, 4, base::MakeUnique<base::Value>(0x7331));
64 64
65 BluetoothServiceAttributeValueBlueZ* value4 = 65 BluetoothServiceAttributeValueBlueZ* value4 =
66 new BluetoothServiceAttributeValueBlueZ( 66 new BluetoothServiceAttributeValueBlueZ(
67 MakeSequence({value1, value2, value3})); 67 MakeSequence({value1, value2, value3}));
68 68
69 BluetoothServiceAttributeValueBlueZ value = *value4; 69 BluetoothServiceAttributeValueBlueZ value = *value4;
70 delete value4; 70 delete value4;
71 71
72 EXPECT_EQ(3u, value.size()); 72 EXPECT_EQ(3u, value.size());
73 const Sequence& s = value.sequence(); 73 const Sequence& s = value.sequence();
74 EXPECT_EQ(3u, s.size()); 74 EXPECT_EQ(3u, s.size());
75 75
76 CheckUuidValue(s[0], kServiceUuid); 76 CheckUuidValue(s[0], kServiceUuid);
77 CheckIntValue(s[2], 0x7331); // Checking out of order by intention. 77 CheckIntValue(s[2], 0x7331); // Checking out of order by intention.
78 CheckIntValue(s[1], 0x1337); 78 CheckIntValue(s[1], 0x1337);
79 } 79 }
80 80
81 TEST(BluetoothServiceAttributeBlueZTest, NestedValue) { 81 TEST(BluetoothServiceAttributeBlueZTest, NestedValue) {
82 BluetoothServiceAttributeValueBlueZ value1( 82 BluetoothServiceAttributeValueBlueZ value1(
83 Type::UUID, 16, base::MakeUnique<base::StringValue>(kServiceUuid)); 83 Type::UUID, 16, base::MakeUnique<base::StringValue>(kServiceUuid));
84 BluetoothServiceAttributeValueBlueZ value2( 84 BluetoothServiceAttributeValueBlueZ value2(
85 Type::INT, 4, base::MakeUnique<base::FundamentalValue>(0x1337)); 85 Type::INT, 4, base::MakeUnique<base::Value>(0x1337));
86 BluetoothServiceAttributeValueBlueZ value3(MakeSequence({value1, value2})); 86 BluetoothServiceAttributeValueBlueZ value3(MakeSequence({value1, value2}));
87 BluetoothServiceAttributeValueBlueZ value4(MakeSequence({value3})); 87 BluetoothServiceAttributeValueBlueZ value4(MakeSequence({value3}));
88 88
89 BluetoothServiceAttributeValueBlueZ* value5 = 89 BluetoothServiceAttributeValueBlueZ* value5 =
90 new BluetoothServiceAttributeValueBlueZ( 90 new BluetoothServiceAttributeValueBlueZ(
91 MakeSequence({value1, value2, value3, value4})); 91 MakeSequence({value1, value2, value3, value4}));
92 BluetoothServiceAttributeValueBlueZ value = *value5; 92 BluetoothServiceAttributeValueBlueZ value = *value5;
93 delete value5; 93 delete value5;
94 94
95 // Check outer layer first. 95 // Check outer layer first.
(...skipping 23 matching lines...) Expand all
119 const Sequence& v31 = v4[0].sequence(); 119 const Sequence& v31 = v4[0].sequence();
120 EXPECT_EQ(2u, v31.size()); 120 EXPECT_EQ(2u, v31.size());
121 CheckUuidValue(v31[0], kServiceUuid); 121 CheckUuidValue(v31[0], kServiceUuid);
122 CheckIntValue(v31[1], 0x1337); 122 CheckIntValue(v31[1], 0x1337);
123 } 123 }
124 124
125 TEST(BluetoothServiceAttributeBlueZTest, CopyAssignment) { 125 TEST(BluetoothServiceAttributeBlueZTest, CopyAssignment) {
126 BluetoothServiceAttributeValueBlueZ value1( 126 BluetoothServiceAttributeValueBlueZ value1(
127 Type::UUID, 16, base::MakeUnique<base::StringValue>(kServiceUuid)); 127 Type::UUID, 16, base::MakeUnique<base::StringValue>(kServiceUuid));
128 BluetoothServiceAttributeValueBlueZ value2( 128 BluetoothServiceAttributeValueBlueZ value2(
129 Type::INT, 4, base::MakeUnique<base::FundamentalValue>(0x1337)); 129 Type::INT, 4, base::MakeUnique<base::Value>(0x1337));
130 BluetoothServiceAttributeValueBlueZ value3( 130 BluetoothServiceAttributeValueBlueZ value3(
131 Type::INT, 4, base::MakeUnique<base::FundamentalValue>(0x7331)); 131 Type::INT, 4, base::MakeUnique<base::Value>(0x7331));
132 std::unique_ptr<BluetoothServiceAttributeValueBlueZ> value4( 132 std::unique_ptr<BluetoothServiceAttributeValueBlueZ> value4(
133 new BluetoothServiceAttributeValueBlueZ( 133 new BluetoothServiceAttributeValueBlueZ(
134 MakeSequence({value1, value2, value3}))); 134 MakeSequence({value1, value2, value3})));
135 135
136 BluetoothServiceAttributeValueBlueZ value; 136 BluetoothServiceAttributeValueBlueZ value;
137 137
138 value = *value4; 138 value = *value4;
139 value4 = nullptr; 139 value4 = nullptr;
140 140
141 EXPECT_EQ(3u, value.size()); 141 EXPECT_EQ(3u, value.size());
142 const Sequence& s = value.sequence(); 142 const Sequence& s = value.sequence();
143 EXPECT_EQ(3u, s.size()); 143 EXPECT_EQ(3u, s.size());
144 144
145 CheckUuidValue(s[0], kServiceUuid); 145 CheckUuidValue(s[0], kServiceUuid);
146 CheckIntValue(s[2], 0x7331); 146 CheckIntValue(s[2], 0x7331);
147 CheckIntValue(s[1], 0x1337); 147 CheckIntValue(s[1], 0x1337);
148 } 148 }
149 149
150 } // namespace bluez 150 } // namespace bluez
OLDNEW
« no previous file with comments | « dbus/values_util_unittest.cc ('k') | device/bluetooth/dbus/bluetooth_device_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698