Skip to content

Commit

Permalink
Fix a bug in RemoteSet::Get
Browse files Browse the repository at this point in the history
`auto* it` should be `auto it` in map.find().

Bug: None
Test: pass mojo_unittests
Change-Id: Icbea2ea0d2c0e98774c4162084f1c890a68f10cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2938763
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#889367}
  • Loading branch information
alanlxl authored and Chromium LUCI CQ committed Jun 4, 2021
1 parent 442f378 commit fa50ddc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mojo/public/cpp/bindings/remote_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class RemoteSetImpl {
// Returns an `Interface*` for the given ID, that can be used to issue
// interface calls.
Interface* Get(RemoteSetElementId id) {
auto* it = storage_.find(id);
auto it = storage_.find(id);
if (it == storage_.end())
return nullptr;
return it->second.get();
Expand All @@ -148,7 +148,7 @@ class RemoteSetImpl {

void FlushForTesting() {
for (auto& it : storage_) {
it.second.FlushForTesting();
it.second.FlushForTesting();
}
}

Expand Down
18 changes: 14 additions & 4 deletions mojo/public/cpp/bindings/tests/remote_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1257,18 +1257,28 @@ TEST_P(RemoteTest, RemoteSet) {
{
base::RunLoop loop;
constexpr double kValue = 42.0;
auto on_add = base::BarrierClosure(3, loop.QuitClosure());
auto on_add = base::BarrierClosure(6, loop.QuitClosure());
for (auto& remote : remotes) {
remote->Add(kValue, base::BindLambdaForTesting([&](double total) {
EXPECT_EQ(kValue, total);
on_add.Run();
}));
}

// Use Get() to get a specified remote from RemoteSet.
std::vector<mojo::RemoteSetElementId> ids = {id0, id1, id2};
for (auto& id : ids) {
remotes.Get(id)->Add(kValue,
base::BindLambdaForTesting([&](double total) {
EXPECT_EQ(kValue * 2, total);
on_add.Run();
}));
}
loop.Run();

EXPECT_EQ(kValue, impls[0]->total());
EXPECT_EQ(kValue, impls[1]->total());
EXPECT_EQ(kValue, impls[2]->total());
EXPECT_EQ(kValue * 2, impls[0]->total());
EXPECT_EQ(kValue * 2, impls[1]->total());
EXPECT_EQ(kValue * 2, impls[2]->total());
}

EXPECT_FALSE(remotes.empty());
Expand Down

0 comments on commit fa50ddc

Please sign in to comment.