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/proximity_auth/ble/bluetooth_low_energy_weave_packet_genera
tor.h" | 5 #include "components/proximity_auth/ble/bluetooth_low_energy_weave_packet_genera
tor.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using proximity_auth::BluetoothLowEnergyWeavePacketGenerator; | 15 namespace proximity_auth { |
16 | 16 |
17 namespace { | 17 namespace { |
18 typedef BluetoothLowEnergyWeavePacketGenerator::ReasonForClose ReasonForClose; | 18 |
19 typedef BluetoothLowEnergyWeavePacketGenerator::Packet Packet; | 19 typedef BluetoothLowEnergyWeavePacket::Packet Packet; |
| 20 typedef BluetoothLowEnergyWeavePacket::ReasonForClose ReasonForClose; |
20 | 21 |
21 const uint8_t kDefaultPacketSize = 20; | 22 const uint8_t kDefaultPacketSize = 20; |
22 const uint8_t kWeaveVersion = 1; | 23 const uint8_t kWeaveVersion = 1; |
23 const uint8_t kMaxCounter = 8; | 24 const uint8_t kMaxCounter = 8; |
24 const uint8_t kEmptyUpperByte = 0; | 25 const uint8_t kEmptyUpperByte = 0; |
25 const uint8_t kSelectDefaultPacketSize = 0; | 26 const uint8_t kSelectDefaultPacketSize = 0; |
26 const uint8_t kDataType = 0; | 27 const uint8_t kDataType = 0; |
27 | 28 |
28 } // namespace | 29 } // namespace |
29 | 30 |
30 namespace proximity_auth { | |
31 | 31 |
32 class ProximityAuthBluetoothLowEnergyWeavePacketGeneratorTest | 32 class ProximityAuthBluetoothLowEnergyWeavePacketGeneratorTest |
33 : public testing::Test { | 33 : public testing::Test { |
34 protected: | 34 protected: |
35 ProximityAuthBluetoothLowEnergyWeavePacketGeneratorTest() {} | 35 ProximityAuthBluetoothLowEnergyWeavePacketGeneratorTest() {} |
36 | 36 |
37 void TestConnectionCloseWithReason(ReasonForClose reason_for_close, | 37 void TestConnectionCloseWithReason(ReasonForClose reason_for_close, |
38 uint8_t expected_reason_for_close) { | 38 uint8_t expected_reason_for_close) { |
39 std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator> generator = | 39 std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator> generator = |
40 BluetoothLowEnergyWeavePacketGenerator::Factory::NewInstance(); | 40 BluetoothLowEnergyWeavePacketGenerator::Factory::NewInstance(); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 std::vector<Packet> expected(kNumPackets); | 261 std::vector<Packet> expected(kNumPackets); |
262 | 262 |
263 for (uint8_t i = 0; i < kNumPackets; ++i) { | 263 for (uint8_t i = 0; i < kNumPackets; ++i) { |
264 uint8_t header = packets[i][0]; | 264 uint8_t header = packets[i][0]; |
265 EXPECT_EQ(i % kMaxCounter, GetCounterFromHeader(header)); | 265 EXPECT_EQ(i % kMaxCounter, GetCounterFromHeader(header)); |
266 EXPECT_EQ(kDataType, GetPacketType(header)); | 266 EXPECT_EQ(kDataType, GetPacketType(header)); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 } // namespace proximity_auth | 270 } // namespace proximity_auth |
OLD | NEW |