mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
[BLEREFACTOR]: Reset BleSocket streams after closing.
PiperOrigin-RevId: 831610441
This commit is contained in:
committed by
Copybara-Service
parent
a40875d552
commit
e960e72b28
@@ -91,11 +91,16 @@ Exception BleSocket::Close() {
|
||||
}
|
||||
|
||||
Exception BleSocket::CloseLocked() {
|
||||
if (!ble_input_stream_ && !ble_output_stream_) {
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
if (ble_input_stream_) {
|
||||
ble_input_stream_->Close();
|
||||
ble_input_stream_.reset();
|
||||
}
|
||||
if (ble_output_stream_) {
|
||||
ble_output_stream_->Close();
|
||||
ble_output_stream_.reset();
|
||||
}
|
||||
Medium medium = GetMediumLocked();
|
||||
switch (medium) {
|
||||
|
||||
@@ -118,10 +118,10 @@ class BleSocketBleMediumTest : public ::testing::Test {
|
||||
ASSERT_NE(socket_, nullptr);
|
||||
}
|
||||
|
||||
FakeBleSocketImpl* fake_socket_impl_;
|
||||
std::unique_ptr<BleSocket> socket_;
|
||||
FakeInputStream fake_input_stream_;
|
||||
FakeOutputStream fake_output_stream_;
|
||||
FakeBleSocketImpl* fake_socket_impl_;
|
||||
std::unique_ptr<BleSocket> socket_;
|
||||
};
|
||||
|
||||
TEST_F(BleSocketBleMediumTest, CloseSucceeds) {
|
||||
@@ -176,10 +176,10 @@ class BleL2capSocketBleMediumTest : public ::testing::Test {
|
||||
ASSERT_NE(socket_, nullptr);
|
||||
}
|
||||
|
||||
FakeBleL2capSocketImpl* fake_l2cap_socket_impl_;
|
||||
std::unique_ptr<BleSocket> socket_;
|
||||
FakeInputStream fake_input_stream_;
|
||||
FakeOutputStream fake_output_stream_;
|
||||
FakeBleL2capSocketImpl* fake_l2cap_socket_impl_;
|
||||
std::unique_ptr<BleSocket> socket_;
|
||||
};
|
||||
|
||||
TEST_F(BleL2capSocketBleMediumTest, CloseSucceeds) {
|
||||
|
||||
Reference in New Issue
Block a user