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

Side by Side Diff: chromeos/components/tether/ble_advertisement_device_queue_unittest.cc

Issue 2590553003: [CrOS Tether] Create ble_constants.h/cc, which include common constants to be shared among multiple… (Closed)
Patch Set: hansberry@ comments. Created 4 years 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 "chromeos/components/tether/ble_advertisement_device_queue.h" 5 #include "chromeos/components/tether/ble_advertisement_device_queue.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "chromeos/components/tether/ble_constants.h"
9 #include "components/cryptauth/remote_device_test_util.h" 10 #include "components/cryptauth/remote_device_test_util.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using testing::ElementsAre; 14 using testing::ElementsAre;
14 15
15 namespace chromeos { 16 namespace chromeos {
16 17
17 namespace tether { 18 namespace tether {
18 19
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 device_queue_->MoveDeviceToEnd(devices[0].GetDeviceId()); 88 device_queue_->MoveDeviceToEnd(devices[0].GetDeviceId());
88 to_advertise = device_queue_->GetDevicesToWhichToAdvertise(); 89 to_advertise = device_queue_->GetDevicesToWhichToAdvertise();
89 EXPECT_THAT(to_advertise, ElementsAre(devices[1], devices[0])); 90 EXPECT_THAT(to_advertise, ElementsAre(devices[1], devices[0]));
90 91
91 device_queue_->MoveDeviceToEnd(devices[1].GetDeviceId()); 92 device_queue_->MoveDeviceToEnd(devices[1].GetDeviceId());
92 to_advertise = device_queue_->GetDevicesToWhichToAdvertise(); 93 to_advertise = device_queue_->GetDevicesToWhichToAdvertise();
93 EXPECT_THAT(to_advertise, ElementsAre(devices[0], devices[1])); 94 EXPECT_THAT(to_advertise, ElementsAre(devices[0], devices[1]));
94 } 95 }
95 96
96 TEST_F(BleAdvertisementDeviceQueueTest, TestThreeDevices) { 97 TEST_F(BleAdvertisementDeviceQueueTest, TestThreeDevices) {
97 // Note: These tests need to be rewritten if MAX_CONCURRENT_ADVERTISEMENTS is 98 // Note: These tests need to be rewritten if |kMaxConcurrentAdvertisements| is
98 // ever changed. 99 // ever changed.
99 ASSERT_GT(3, BleAdvertisementDeviceQueue::kMaxConcurrentAdvertisements); 100 ASSERT_GT(3, kMaxConcurrentAdvertisements);
100 101
101 std::vector<cryptauth::RemoteDevice> devices = 102 std::vector<cryptauth::RemoteDevice> devices =
102 cryptauth::GenerateTestRemoteDevices(3); 103 cryptauth::GenerateTestRemoteDevices(3);
103 EXPECT_TRUE(device_queue_->SetDevices(devices)); 104 EXPECT_TRUE(device_queue_->SetDevices(devices));
104 EXPECT_EQ(static_cast<size_t>(3), device_queue_->GetSize()); 105 EXPECT_EQ(static_cast<size_t>(3), device_queue_->GetSize());
105 106
106 std::vector<cryptauth::RemoteDevice> to_advertise = 107 std::vector<cryptauth::RemoteDevice> to_advertise =
107 device_queue_->GetDevicesToWhichToAdvertise(); 108 device_queue_->GetDevicesToWhichToAdvertise();
108 EXPECT_THAT(to_advertise, ElementsAre(devices[0], devices[1])); 109 EXPECT_THAT(to_advertise, ElementsAre(devices[0], devices[1]));
109 110
110 device_queue_->MoveDeviceToEnd(devices[0].GetDeviceId()); 111 device_queue_->MoveDeviceToEnd(devices[0].GetDeviceId());
111 to_advertise = device_queue_->GetDevicesToWhichToAdvertise(); 112 to_advertise = device_queue_->GetDevicesToWhichToAdvertise();
112 EXPECT_THAT(to_advertise, ElementsAre(devices[1], devices[2])); 113 EXPECT_THAT(to_advertise, ElementsAre(devices[1], devices[2]));
113 114
114 device_queue_->MoveDeviceToEnd(devices[1].GetDeviceId()); 115 device_queue_->MoveDeviceToEnd(devices[1].GetDeviceId());
115 to_advertise = device_queue_->GetDevicesToWhichToAdvertise(); 116 to_advertise = device_queue_->GetDevicesToWhichToAdvertise();
116 EXPECT_THAT(to_advertise, ElementsAre(devices[2], devices[0])); 117 EXPECT_THAT(to_advertise, ElementsAre(devices[2], devices[0]));
117 118
118 device_queue_->MoveDeviceToEnd(devices[2].GetDeviceId()); 119 device_queue_->MoveDeviceToEnd(devices[2].GetDeviceId());
119 to_advertise = device_queue_->GetDevicesToWhichToAdvertise(); 120 to_advertise = device_queue_->GetDevicesToWhichToAdvertise();
120 EXPECT_THAT(to_advertise, ElementsAre(devices[0], devices[1])); 121 EXPECT_THAT(to_advertise, ElementsAre(devices[0], devices[1]));
121 } 122 }
122 123
123 TEST_F(BleAdvertisementDeviceQueueTest, TestAddingDevices) { 124 TEST_F(BleAdvertisementDeviceQueueTest, TestAddingDevices) {
124 // Note: These tests need to be rewritten if MAX_CONCURRENT_ADVERTISEMENTS is 125 // Note: These tests need to be rewritten if |kMaxConcurrentAdvertisements| is
125 // ever changed. 126 // ever changed.
126 ASSERT_GT(3, BleAdvertisementDeviceQueue::kMaxConcurrentAdvertisements); 127 ASSERT_GT(3, kMaxConcurrentAdvertisements);
127 128
128 std::vector<cryptauth::RemoteDevice> all_devices = 129 std::vector<cryptauth::RemoteDevice> all_devices =
129 cryptauth::GenerateTestRemoteDevices(5); 130 cryptauth::GenerateTestRemoteDevices(5);
130 std::vector<cryptauth::RemoteDevice> initial_devices = {all_devices[0], 131 std::vector<cryptauth::RemoteDevice> initial_devices = {all_devices[0],
131 all_devices[1]}; 132 all_devices[1]};
132 std::vector<cryptauth::RemoteDevice> updated_devices_list = { 133 std::vector<cryptauth::RemoteDevice> updated_devices_list = {
133 all_devices[1], all_devices[2], all_devices[3], all_devices[4]}; 134 all_devices[1], all_devices[2], all_devices[3], all_devices[4]};
134 135
135 EXPECT_TRUE(device_queue_->SetDevices(initial_devices)); 136 EXPECT_TRUE(device_queue_->SetDevices(initial_devices));
136 EXPECT_EQ(static_cast<size_t>(2), device_queue_->GetSize()); 137 EXPECT_EQ(static_cast<size_t>(2), device_queue_->GetSize());
(...skipping 27 matching lines...) Expand all
164 EXPECT_TRUE(device_queue_->SetDevices(devices)); 165 EXPECT_TRUE(device_queue_->SetDevices(devices));
165 EXPECT_FALSE(device_queue_->SetDevices(devices)); 166 EXPECT_FALSE(device_queue_->SetDevices(devices));
166 EXPECT_FALSE(device_queue_->SetDevices(devices)); 167 EXPECT_FALSE(device_queue_->SetDevices(devices));
167 EXPECT_TRUE( 168 EXPECT_TRUE(
168 device_queue_->SetDevices(cryptauth::GenerateTestRemoteDevices(3))); 169 device_queue_->SetDevices(cryptauth::GenerateTestRemoteDevices(3)));
169 } 170 }
170 171
171 } // namespace tether 172 } // namespace tether
172 173
173 } // namespace cryptauth 174 } // namespace cryptauth
OLDNEW
« no previous file with comments | « chromeos/components/tether/ble_advertisement_device_queue.cc ('k') | chromeos/components/tether/ble_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698