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

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

Issue 2098653002: device/bluetooth/bluez: add discoverable timeout adapter property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adding test 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
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
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 const uint32_t kShortDiscoverableTimeout = 30;
ortuno 2016/06/24 20:35:53 nit: Can you use constexpr here?
4167 const 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(adapter_bluez->GetDiscoverableTimeout(), kShortDiscoverableTimeout);
ortuno 2016/06/24 20:35:53 Swap these two arguments. The first value should b
4175
4176 fake_bluetooth_adapter_client_->SetDiscoverableTimeout(
4177 kLongDiscoverableTimeout);
4178 EXPECT_EQ(adapter_bluez->GetDiscoverableTimeout(), kLongDiscoverableTimeout);
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
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
OLDNEW
« no previous file with comments | « device/bluetooth/bluez/bluetooth_adapter_bluez.cc ('k') | device/bluetooth/dbus/fake_bluetooth_adapter_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698