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

Unified Diff: components/arc/test/fake_app_instance.cc

Issue 2146573005: Revert of arc: Use the new InstanceHolder for unittests (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@bridge_refactor_first
Patch Set: 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/arc/test/fake_app_instance.h ('k') | components/arc/test/fake_notifications_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « components/arc/test/fake_app_instance.h ('k') | components/arc/test/fake_notifications_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698