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

Unified Diff: device/bluetooth/device_unittest.cc

Issue 2643393002: bluetooth: Remove queuing of GetCharacteristicsCallbacks (Closed)
Patch Set: Add comment explaining null/empty difference Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/device.cc ('k') | device/bluetooth/public/interfaces/device.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/device_unittest.cc
diff --git a/device/bluetooth/device_unittest.cc b/device/bluetooth/device_unittest.cc
index 6493e3d86d31b2456f7a0ce3d49e71cd5b40cdbd..51e150efed5a3588f0a5d94bf638b74477d2f76f 100644
--- a/device/bluetooth/device_unittest.cc
+++ b/device/bluetooth/device_unittest.cc
@@ -179,32 +179,6 @@ class BluetoothInterfaceDeviceTest : public testing::Test {
expected_callback_count_++);
}
- void CheckGetCharacteristicsCountImpl(
- Call expected,
- size_t expected_count,
- int num_of_preceding_calls,
- std::vector<mojom::CharacteristicInfoPtr> characteristics) {
- EXPECT_EQ(num_of_preceding_calls, actual_callback_count_);
- ++actual_callback_count_;
-
- if (expected == Call::EXPECTED)
- ++actual_success_callback_calls_;
-
- EXPECT_EQ(expected_count, characteristics.size());
- }
-
- Device::GetCharacteristicsCallback CheckGetCharacteristicsCount(
- Call expected,
- int expected_count) {
- if (expected == Call::EXPECTED)
- ++expected_success_callback_calls_;
-
- return base::Bind(
- &BluetoothInterfaceDeviceTest::CheckGetCharacteristicsCountImpl,
- weak_factory_.GetWeakPtr(), expected, expected_count,
- expected_callback_count_++);
- }
-
scoped_refptr<NiceMockBluetoothAdapter> adapter_;
NiceMockBluetoothDevice device_;
base::MessageLoop message_loop_;
@@ -298,91 +272,4 @@ TEST_F(BluetoothInterfaceDeviceTest,
// Wait for message pipe to process error.
base::RunLoop().RunUntilIdle();
}
-
-TEST_F(BluetoothInterfaceDeviceTest, GetCharacteristics) {
- EXPECT_CALL(device_, IsGattServicesDiscoveryComplete())
- .WillRepeatedly(Return(true));
-
- proxy_->GetCharacteristics(kTestServiceId0,
- CheckGetCharacteristicsCount(Call::EXPECTED, 2));
-
- base::RunLoop().RunUntilIdle();
-}
-
-TEST_F(BluetoothInterfaceDeviceTest, GetCharacteristicsNotDiscovered) {
- EXPECT_CALL(device_, IsGattServicesDiscoveryComplete())
- .WillOnce(Return(false))
- .WillOnce(Return(false))
- .WillRepeatedly(Return(true));
-
- // Client: Sends multiple requests for characteristics.
- proxy_->GetCharacteristics(kTestServiceId0,
- CheckGetCharacteristicsCount(Call::EXPECTED, 2));
- proxy_->GetCharacteristics(kTestServiceId1,
- CheckGetCharacteristicsCount(Call::EXPECTED, 1));
-
- base::RunLoop().RunUntilIdle();
-
- SimulateGattServicesDiscovered();
-
- // No more GetCharacteristics calls will complete.
- SimulateGattServicesDiscovered();
-
- base::RunLoop().RunUntilIdle();
-
- // Client: Sends more requests which run immediately.
- proxy_->GetCharacteristics(kTestServiceId0,
- CheckGetCharacteristicsCount(Call::EXPECTED, 2));
- proxy_->GetCharacteristics(kTestServiceId1,
- CheckGetCharacteristicsCount(Call::EXPECTED, 1));
-
- base::RunLoop().RunUntilIdle();
-
- // No more GetCharacteristics calls will complete.
- SimulateGattServicesDiscovered();
-
- // Wait for message pipe to process error.
- base::RunLoop().RunUntilIdle();
-}
-
-TEST_F(BluetoothInterfaceDeviceTest,
- GetCharacteristicsLostConnectionWithPendingRequests) {
- EXPECT_CALL(device_, IsGattServicesDiscoveryComplete())
- .WillRepeatedly(Return(false));
- // Client: Sends multiple requests for characteristics.
- proxy_->GetCharacteristics(
- kTestServiceId0, CheckGetCharacteristicsCount(Call::NOT_EXPECTED, 2));
- proxy_->GetCharacteristics(
- kTestServiceId1, CheckGetCharacteristicsCount(Call::NOT_EXPECTED, 1));
- EXPECT_EQ(0, actual_callback_count_);
-
- // Simulate connection loss.
- device_.SetConnected(false);
- SimulateDeviceChanged();
- expect_device_service_deleted_ = true;
-
- // Wait for message pipe to process error.
- base::RunLoop().RunUntilIdle();
-}
-
-TEST_F(BluetoothInterfaceDeviceTest,
- GetCharacteristicsForcedDisconnectionWithPendingRequests) {
- EXPECT_CALL(device_, IsGattServicesDiscoveryComplete())
- .WillRepeatedly(Return(false));
-
- // Client: Sends multiple requests for characteristics.
- proxy_->GetCharacteristics(
- kTestServiceId0, CheckGetCharacteristicsCount(Call::NOT_EXPECTED, 2));
- proxy_->GetCharacteristics(
- kTestServiceId1, CheckGetCharacteristicsCount(Call::NOT_EXPECTED, 1));
- EXPECT_EQ(0, actual_callback_count_);
-
- // Simulate connection loss.
- proxy_->Disconnect();
- expect_device_service_deleted_ = true;
-
- // Wait for message pipe to process error.
- base::RunLoop().RunUntilIdle();
-}
-
} // namespace bluetooth
« no previous file with comments | « device/bluetooth/device.cc ('k') | device/bluetooth/public/interfaces/device.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698