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

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

Issue 2046283003: Add unit test for ArcBluetoothBridge and TypeConverter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt
Patch Set: Use fake dbus client instead of mock Bluetooth type Created 4 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/arc/bluetooth/bluetooth_type_converters.h"
6
7 #include <string>
8 #include <vector>
9
10 #include "device/bluetooth/bluetooth_gatt_service.h"
11 #include "device/bluetooth/bluetooth_uuid.h"
12 #include "mojo/public/cpp/bindings/array.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace mojo {
16
17 TEST(BluetoothTypeConvertorTest, ConvertMojoBluetoothAddressFromString) {
18 const std::string kAddressStr = "1A:2B:3C:4D:5E:6F";
19 const uint8_t kAddressArray[] = {0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f};
20 const size_t kAddressSize = 6;
21
22 arc::mojom::BluetoothAddressPtr addressMojo =
23 arc::mojom::BluetoothAddress::From(kAddressStr);
24 EXPECT_EQ(kAddressSize, addressMojo->address.size());
25 for (size_t i = 0; i < kAddressSize; i++) {
26 EXPECT_EQ(kAddressArray[i], addressMojo->address[i]);
27 }
28 }
29
30 TEST(BluetoothTypeConvertorTest, ConvertMojoBluetoothAddressToString) {
31 const std::string kAddressStr = "1A:2B:3C:4D:5E:6F";
32 const uint8_t kAddressArray[] = {0x1a, 0x2b, 0x3c, 0x4d, 0x5e, 0x6f};
33 const size_t kAddressSize = 6;
34
35 arc::mojom::BluetoothAddressPtr addressMojo =
36 arc::mojom::BluetoothAddress::New();
37 for (size_t i = 0; i < kAddressSize; i++) {
38 addressMojo->address.push_back(kAddressArray[i]);
39 }
40 EXPECT_EQ(kAddressStr, addressMojo->To<std::string>());
41 }
42
43 TEST(BluetoothTypeConvertorTest,
44 ConvertMojoBluetoothUUIDFromDeviceBluetoothUUID) {
45 const std::string kUuidStr = "12345678-1234-5678-9abc-def123456789";
46 const uint8_t kUuidArray[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78,
47 0x9a, 0xbc, 0xde, 0xf1, 0x23, 0x45, 0x67, 0x89};
48 const size_t kUuidSize = 16;
49
50 device::BluetoothUUID uuidDevice(kUuidStr);
51 arc::mojom::BluetoothUUIDPtr uuidMojo =
52 arc::mojom::BluetoothUUID::From(uuidDevice);
53 EXPECT_EQ(kUuidSize, uuidMojo->uuid.size());
54 for (size_t i = 0; i < kUuidSize; i++) {
55 EXPECT_EQ(kUuidArray[i], uuidMojo->uuid[i]);
56 }
57 }
58
59 TEST(BluetoothTypeConvertorTest,
60 ConvertMojoBluetoothUUIDToDeviceBluetoothUUID) {
61 const std::string kUuidStr = "12345678-1234-5678-9abc-def123456789";
62 const uint8_t kUuidArray[] = {0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78,
63 0x9a, 0xbc, 0xde, 0xf1, 0x23, 0x45, 0x67, 0x89};
64 const size_t kUuidSize = 16;
65
66 arc::mojom::BluetoothUUIDPtr uuidMojo = arc::mojom::BluetoothUUID::New();
67 for (size_t i = 0; i < kUuidSize; i++) {
68 uuidMojo->uuid.push_back(kUuidArray[i]);
69 }
70 EXPECT_EQ(kUuidStr, uuidMojo.To<device::BluetoothUUID>().canonical_value());
71 }
72
73 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698