Index: components/arc/test/fake_app_instance.cc |
diff --git a/components/arc/test/fake_app_instance.cc b/components/arc/test/fake_app_instance.cc |
index 64822b753a92bead33f4e07fe6eb441e5bb39514..919d3937ebe10d6a669c0dccc193f8401526716a 100644 |
--- a/components/arc/test/fake_app_instance.cc |
+++ b/components/arc/test/fake_app_instance.cc |
@@ -38,7 +38,7 @@ |
namespace arc { |
FakeAppInstance::FakeAppInstance(mojom::AppHost* app_host) |
- : app_host_(app_host) {} |
+ : binding_(this), app_host_(app_host) {} |
FakeAppInstance::~FakeAppInstance() {} |
void FakeAppInstance::RefreshAppList() { |
@@ -166,6 +166,25 @@ |
app_host_->OnPackageRemoved(package_name); |
} |
+void FakeAppInstance::WaitForIncomingMethodCall() { |
+ binding_.WaitForIncomingMethodCall(); |
+} |
+ |
+void FakeAppInstance::WaitForOnAppInstanceReady() { |
+ // Several messages are sent back and forth when OnAppInstanceReady() is |
+ // called. Normally, it would be preferred to use a single |
+ // WaitForIncomingMethodCall() to wait for each method individually, but |
+ // QueryVersion() does require processing on the I/O thread, so |
+ // RunUntilIdle() is required to correctly dispatch it. On slower machines |
+ // (and when running under Valgrind), the two thread hops needed to send and |
+ // dispatch each Mojo message might not be picked up by a single |
+ // RunUntilIdle(), so keep pumping the message loop until all expected |
+ // messages are. |
+ while (refresh_app_list_count_ != 1) { |
+ base::RunLoop().RunUntilIdle(); |
+ } |
+} |
+ |
void FakeAppInstance::CanHandleResolution( |
const mojo::String& package_name, |
const mojo::String& activity, |