OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 4144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4155 // Calling GetConnectionInfo for a connected device should return valid | 4155 // Calling GetConnectionInfo for a connected device should return valid |
4156 // results. | 4156 // results. |
4157 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); | 4157 fake_bluetooth_device_client_->UpdateConnectionInfo(-10, 3, 4); |
4158 BluetoothDevice::ConnectionInfo conn_info; | 4158 BluetoothDevice::ConnectionInfo conn_info; |
4159 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); | 4159 device->GetConnectionInfo(base::Bind(&SaveConnectionInfo, &conn_info)); |
4160 EXPECT_EQ(-10, conn_info.rssi); | 4160 EXPECT_EQ(-10, conn_info.rssi); |
4161 EXPECT_EQ(3, conn_info.transmit_power); | 4161 EXPECT_EQ(3, conn_info.transmit_power); |
4162 EXPECT_EQ(4, conn_info.max_transmit_power); | 4162 EXPECT_EQ(4, conn_info.max_transmit_power); |
4163 } | 4163 } |
4164 | 4164 |
| 4165 TEST_F(BluetoothBlueZTest, GetDiscoverableTimeout) { |
| 4166 constexpr uint32_t kShortDiscoverableTimeout = 30; |
| 4167 constexpr uint32_t kLongDiscoverableTimeout = 240; |
| 4168 GetAdapter(); |
| 4169 BluetoothAdapterBlueZ* adapter_bluez = |
| 4170 static_cast<BluetoothAdapterBlueZ*>(adapter_.get()); |
| 4171 |
| 4172 fake_bluetooth_adapter_client_->SetDiscoverableTimeout( |
| 4173 kShortDiscoverableTimeout); |
| 4174 EXPECT_EQ(kShortDiscoverableTimeout, adapter_bluez->GetDiscoverableTimeout()); |
| 4175 |
| 4176 fake_bluetooth_adapter_client_->SetDiscoverableTimeout( |
| 4177 kLongDiscoverableTimeout); |
| 4178 EXPECT_EQ(kLongDiscoverableTimeout, adapter_bluez->GetDiscoverableTimeout()); |
| 4179 } |
| 4180 |
4165 // Verifies Shutdown shuts down the adapter as expected. | 4181 // Verifies Shutdown shuts down the adapter as expected. |
4166 TEST_F(BluetoothBlueZTest, Shutdown) { | 4182 TEST_F(BluetoothBlueZTest, Shutdown) { |
4167 // Set up adapter. Set powered & discoverable, start discovery. | 4183 // Set up adapter. Set powered & discoverable, start discovery. |
4168 GetAdapter(); | 4184 GetAdapter(); |
4169 adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); | 4185 adapter_->SetPowered(true, GetCallback(), GetErrorCallback()); |
4170 adapter_->SetDiscoverable(true, GetCallback(), GetErrorCallback()); | 4186 adapter_->SetDiscoverable(true, GetCallback(), GetErrorCallback()); |
4171 adapter_->StartDiscoverySession( | 4187 adapter_->StartDiscoverySession( |
4172 base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, | 4188 base::Bind(&BluetoothBlueZTest::DiscoverySessionCallback, |
4173 base::Unretained(this)), | 4189 base::Unretained(this)), |
4174 GetErrorCallback()); | 4190 GetErrorCallback()); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4481 adapter_->Shutdown(); | 4497 adapter_->Shutdown(); |
4482 adapter_bluez->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); | 4498 adapter_bluez->OnStopDiscoveryError(GetDiscoveryErrorCallback(), "", ""); |
4483 | 4499 |
4484 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, | 4500 // 1 error reported to RemoveDiscoverySession because of OnStopDiscoveryError, |
4485 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. | 4501 // and kNumberOfDiscoverySessions errors queued with AddDiscoverySession. |
4486 EXPECT_EQ(0, callback_count_); | 4502 EXPECT_EQ(0, callback_count_); |
4487 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); | 4503 EXPECT_EQ(1 + kNumberOfDiscoverySessions, error_callback_count_); |
4488 } | 4504 } |
4489 | 4505 |
4490 } // namespace bluez | 4506 } // namespace bluez |
OLD | NEW |