Commit cdcb0262 authored by Wez's avatar Wez Committed by Commit Bot

Add missing message-received expectation to IPCMojoBootstrapTest.

Some of these tests expected a message from the child process, and would
verify that it was valid/invalid as expected, but would still pass if
no message were received at all.

Bug: 816620
Change-Id: Ie8acf85086f4416c7023118673c40d00a2e190d7
Reviewed-on: https://chromium-review.googlesource.com/955554Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542296}
parent 030c6b95
...@@ -65,7 +65,11 @@ class PeerPidReceiver : public IPC::mojom::Channel { ...@@ -65,7 +65,11 @@ class PeerPidReceiver : public IPC::mojom::Channel {
: binding_(this, std::move(request)), : binding_(this, std::move(request)),
on_peer_pid_set_(on_peer_pid_set), on_peer_pid_set_(on_peer_pid_set),
message_expectation_(message_expectation) {} message_expectation_(message_expectation) {}
~PeerPidReceiver() override {} ~PeerPidReceiver() override {
bool expected_message =
message_expectation_ != MessageExpectation::kNotExpected;
EXPECT_EQ(expected_message, received_message_);
}
// mojom::Channel: // mojom::Channel:
void SetPeerPid(int32_t pid) override { void SetPeerPid(int32_t pid) override {
...@@ -77,6 +81,7 @@ class PeerPidReceiver : public IPC::mojom::Channel { ...@@ -77,6 +81,7 @@ class PeerPidReceiver : public IPC::mojom::Channel {
base::Optional<std::vector<mojo::native::SerializedHandlePtr>> base::Optional<std::vector<mojo::native::SerializedHandlePtr>>
handles) override { handles) override {
ASSERT_NE(MessageExpectation::kNotExpected, message_expectation_); ASSERT_NE(MessageExpectation::kNotExpected, message_expectation_);
received_message_ = true;
IPC::Message message(reinterpret_cast<const char*>(data.data()), IPC::Message message(reinterpret_cast<const char*>(data.data()),
static_cast<uint32_t>(data.size())); static_cast<uint32_t>(data.size()));
...@@ -97,6 +102,8 @@ class PeerPidReceiver : public IPC::mojom::Channel { ...@@ -97,6 +102,8 @@ class PeerPidReceiver : public IPC::mojom::Channel {
MessageExpectation message_expectation_; MessageExpectation message_expectation_;
int32_t peer_pid_ = -1; int32_t peer_pid_ = -1;
bool received_message_ = false;
DISALLOW_COPY_AND_ASSIGN(PeerPidReceiver); DISALLOW_COPY_AND_ASSIGN(PeerPidReceiver);
}; };
......
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