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

Unified Diff: components/leveldb/remote_iterator_unittest.cc

Issue 2096293002: Eliminate usage of InterfacePtr::WaitForIncomingResponse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix trybots failure Created 4 years, 5 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 | « components/leveldb/leveldb_service_unittest.cc ('k') | mash/catalog_viewer/catalog_viewer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/leveldb/remote_iterator_unittest.cc
diff --git a/components/leveldb/remote_iterator_unittest.cc b/components/leveldb/remote_iterator_unittest.cc
index bd6167981913fb1a89c4736777ba6c442b82814f..8e265511835a689df38b81d3d8b7802e1412d574 100644
--- a/components/leveldb/remote_iterator_unittest.cc
+++ b/components/leveldb/remote_iterator_unittest.cc
@@ -4,7 +4,9 @@
#include <map>
+#include "base/bind.h"
#include "base/macros.h"
+#include "base/run_loop.h"
#include "components/leveldb/public/cpp/remote_iterator.h"
#include "components/leveldb/public/interfaces/leveldb.mojom.h"
#include "mojo/common/common_type_converters.h"
@@ -15,11 +17,17 @@ namespace leveldb {
namespace {
template <typename T>
-void DoCapture(T* t, T got_t) { *t = std::move(got_t); }
+void DoCapture(T* t, const base::Closure& quit_closure, T got_t) {
+ *t = std::move(got_t);
+ if (!quit_closure.is_null())
+ quit_closure.Run();
+}
template <typename T1>
-base::Callback<void(T1)> Capture(T1* t1) {
- return base::Bind(&DoCapture<T1>, t1);
+base::Callback<void(T1)> Capture(
+ T1* t1,
+ const base::Closure& quit_closure = base::Closure()) {
+ return base::Bind(&DoCapture<T1>, t1, quit_closure);
}
class RemoteIteratorTest : public shell::test::ShellTest {
@@ -34,8 +42,10 @@ class RemoteIteratorTest : public shell::test::ShellTest {
connector()->ConnectToInterface("mojo:leveldb", &leveldb_);
mojom::DatabaseError error;
- leveldb()->OpenInMemory(GetProxy(&database_), Capture(&error));
- ASSERT_TRUE(leveldb().WaitForIncomingResponse());
+ base::RunLoop run_loop;
+ leveldb()->OpenInMemory(GetProxy(&database_),
+ Capture(&error, run_loop.QuitClosure()));
+ run_loop.Run();
EXPECT_EQ(mojom::DatabaseError::OK, error);
std::map<std::string, std::string> data{
@@ -44,9 +54,11 @@ class RemoteIteratorTest : public shell::test::ShellTest {
for (auto p : data) {
// Write a key to the database.
error = mojom::DatabaseError::INVALID_ARGUMENT;
+ base::RunLoop run_loop;
database_->Put(mojo::Array<uint8_t>::From(p.first),
- mojo::Array<uint8_t>::From(p.second), Capture(&error));
- ASSERT_TRUE(database_.WaitForIncomingResponse());
+ mojo::Array<uint8_t>::From(p.second),
+ Capture(&error, run_loop.QuitClosure()));
+ run_loop.Run();
EXPECT_EQ(mojom::DatabaseError::OK, error);
}
}
@@ -68,8 +80,9 @@ class RemoteIteratorTest : public shell::test::ShellTest {
TEST_F(RemoteIteratorTest, Seeking) {
uint64_t iterator_id = 0;
- database()->NewIterator(Capture(&iterator_id));
- ASSERT_TRUE(database().WaitForIncomingResponse());
+ base::RunLoop run_loop;
+ database()->NewIterator(Capture(&iterator_id, run_loop.QuitClosure()));
+ run_loop.Run();
EXPECT_NE(0u, iterator_id);
RemoteIterator it(database().get(), iterator_id);
@@ -93,8 +106,9 @@ TEST_F(RemoteIteratorTest, Seeking) {
TEST_F(RemoteIteratorTest, Next) {
uint64_t iterator_id = 0;
- database()->NewIterator(Capture(&iterator_id));
- ASSERT_TRUE(database().WaitForIncomingResponse());
+ base::RunLoop run_loop;
+ database()->NewIterator(Capture(&iterator_id, run_loop.QuitClosure()));
+ run_loop.Run();
EXPECT_NE(0u, iterator_id);
RemoteIterator it(database().get(), iterator_id);
@@ -121,8 +135,9 @@ TEST_F(RemoteIteratorTest, Next) {
TEST_F(RemoteIteratorTest, Prev) {
uint64_t iterator_id = 0;
- database()->NewIterator(Capture(&iterator_id));
- ASSERT_TRUE(database().WaitForIncomingResponse());
+ base::RunLoop run_loop;
+ database()->NewIterator(Capture(&iterator_id, run_loop.QuitClosure()));
+ run_loop.Run();
EXPECT_NE(0u, iterator_id);
RemoteIterator it(database().get(), iterator_id);
« no previous file with comments | « components/leveldb/leveldb_service_unittest.cc ('k') | mash/catalog_viewer/catalog_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698