| Index: chrome/browser/ui/app_list/arc/arc_app_unittest.cc
|
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
|
| index 9321c439787aebbf73b40693373124b65fab17ec..55cb189dd5216145069c734a34b960357210a129 100644
|
| --- a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
|
| +++ b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
|
| @@ -66,6 +66,9 @@ class ArcAppModelBuilderTest : public AppListTestBase {
|
| arc::AppInstancePtr instance;
|
| app_instance_->Bind(mojo::GetProxy(&instance));
|
| bridge_service_->OnAppInstanceReady(std::move(instance));
|
| + // Wait for Init() and then RefreshAppList().
|
| + app_instance_->WaitForIncomingMethodCall();
|
| + app_instance_->WaitForIncomingMethodCall();
|
|
|
| // Check initial conditions.
|
| EXPECT_EQ(bridge_service_.get(), arc::ArcBridgeService::Get());
|
| @@ -217,10 +220,12 @@ class ArcAppModelBuilderTest : public AppListTestBase {
|
| };
|
|
|
| TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) {
|
| - EXPECT_EQ(0, app_instance()->refresh_app_list_count());
|
| + // There should already have been one call, when the interface was
|
| + // registered.
|
| + EXPECT_EQ(1, app_instance()->refresh_app_list_count());
|
| bridge_service()->SetReady();
|
| app_instance()->RefreshAppList();
|
| - EXPECT_EQ(1, app_instance()->refresh_app_list_count());
|
| + EXPECT_EQ(2, app_instance()->refresh_app_list_count());
|
| }
|
|
|
| TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) {
|
| @@ -299,11 +304,11 @@ TEST_F(ArcAppModelBuilderTest, LaunchApps) {
|
| ASSERT_NE(nullptr, item_first);
|
| ASSERT_NE(nullptr, item_last);
|
| item_first->Activate(0);
|
| + app_instance()->WaitForIncomingMethodCall();
|
| item_last->Activate(0);
|
| + app_instance()->WaitForIncomingMethodCall();
|
| item_first->Activate(0);
|
| -
|
| - // Process pending tasks.
|
| - base::RunLoop().RunUntilIdle();
|
| + app_instance()->WaitForIncomingMethodCall();
|
|
|
| const ScopedVector<arc::FakeAppInstance::Request>& launch_requests =
|
| app_instance()->launch_requests();
|
| @@ -350,11 +355,19 @@ TEST_F(ArcAppModelBuilderTest, RequestIcons) {
|
| // Process pending tasks.
|
| content::BrowserThread::GetBlockingPool()->FlushForTesting();
|
| base::RunLoop().RunUntilIdle();
|
| + // Normally just one call to RunUntilIdle() suffices to make sure
|
| + // all RequestAppIcon() calls are delivered, but on slower machines
|
| + // (especially when running under Valgrind), they might not get
|
| + // delivered on time. Wait for the remaining tasks individually.
|
| + const size_t expected_size = scale_factors.size() * fake_apps().size();
|
| + while (app_instance()->icon_requests().size() < expected_size) {
|
| + app_instance()->WaitForIncomingMethodCall();
|
| + }
|
|
|
| // At this moment we should receive all requests for icon loading.
|
| const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests =
|
| app_instance()->icon_requests();
|
| - EXPECT_EQ(scale_factors.size() * fake_apps().size(), icon_requests.size());
|
| + EXPECT_EQ(expected_size, icon_requests.size());
|
| std::map<std::string, uint32_t> app_masks;
|
| for (size_t i = 0; i < icon_requests.size(); ++i) {
|
| const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i];
|
|
|