Commit b76eeb9f authored by Alexander Gaponov's avatar Alexander Gaponov Committed by Commit Bot

[Chromecast] Adding correct SetDelegate method to MockGattClient

Currently, there is no way to set expectetions on SetDelegate function
Replaces with MOCK_METHOD1 and moving current function body to
ON_CALL().WillByDefault()

Bug: internal b/132811177

Change-Id: I58ba51d5a0d3dcead895045009de2821271ccfd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1885453Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Reviewed-by: default avatarLuke Halliwell (slow) <halliwell@chromium.org>
Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Commit-Queue: Steven Zhu <jz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710978}
parent ed97857f
...@@ -19,9 +19,7 @@ class MockGattClient : public GattClient { ...@@ -19,9 +19,7 @@ class MockGattClient : public GattClient {
~MockGattClient() override; ~MockGattClient() override;
MOCK_METHOD0(IsSupported, bool()); MOCK_METHOD0(IsSupported, bool());
MOCK_METHOD1(Connect, bool(const Addr&)); MOCK_METHOD1(Connect, bool(const Addr&));
void SetDelegate(Gatt::Client::Delegate* delegate) override { MOCK_METHOD1(SetDelegate, void(Gatt::Client::Delegate*));
delegate_ = delegate;
}
MOCK_METHOD0(Enable, bool()); MOCK_METHOD0(Enable, bool());
MOCK_METHOD0(Disable, bool()); MOCK_METHOD0(Disable, bool());
MOCK_METHOD1(Disconnect, bool(const Addr&)); MOCK_METHOD1(Disconnect, bool(const Addr&));
...@@ -62,7 +60,11 @@ class MockGattClient : public GattClient { ...@@ -62,7 +60,11 @@ class MockGattClient : public GattClient {
Gatt::Client::Delegate* delegate_ = nullptr; Gatt::Client::Delegate* delegate_ = nullptr;
}; };
inline MockGattClient::MockGattClient() = default; inline MockGattClient::MockGattClient() {
ON_CALL(*this, SetDelegate(::testing::_))
.WillByDefault(
[this](Gatt::Client::Delegate* delegate) { delegate_ = delegate; });
}
inline MockGattClient::~MockGattClient() = default; inline MockGattClient::~MockGattClient() = default;
} // namespace bluetooth_v2_shlib } // namespace bluetooth_v2_shlib
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment