OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 app_instance()->SendRefreshAppList(fake_apps()); | 531 app_instance()->SendRefreshAppList(fake_apps()); |
532 | 532 |
533 // Simulate item activate. | 533 // Simulate item activate. |
534 const arc::mojom::AppInfo& app_first = fake_apps()[0]; | 534 const arc::mojom::AppInfo& app_first = fake_apps()[0]; |
535 const arc::mojom::AppInfo& app_last = fake_apps()[0]; | 535 const arc::mojom::AppInfo& app_last = fake_apps()[0]; |
536 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 536 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
537 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); | 537 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); |
538 ASSERT_NE(nullptr, item_first); | 538 ASSERT_NE(nullptr, item_first); |
539 ASSERT_NE(nullptr, item_last); | 539 ASSERT_NE(nullptr, item_last); |
540 item_first->Activate(0); | 540 item_first->Activate(0); |
| 541 app_instance()->WaitForIncomingMethodCall(); |
541 item_last->Activate(0); | 542 item_last->Activate(0); |
| 543 app_instance()->WaitForIncomingMethodCall(); |
542 item_first->Activate(0); | 544 item_first->Activate(0); |
| 545 app_instance()->WaitForIncomingMethodCall(); |
543 | 546 |
544 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = | 547 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = |
545 app_instance()->launch_requests(); | 548 app_instance()->launch_requests(); |
546 ASSERT_EQ(3u, launch_requests.size()); | 549 ASSERT_EQ(3u, launch_requests.size()); |
547 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_first)); | 550 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_first)); |
548 EXPECT_EQ(true, launch_requests[1]->IsForApp(app_last)); | 551 EXPECT_EQ(true, launch_requests[1]->IsForApp(app_last)); |
549 EXPECT_EQ(true, launch_requests[2]->IsForApp(app_first)); | 552 EXPECT_EQ(true, launch_requests[2]->IsForApp(app_first)); |
550 | 553 |
551 // Test an attempt to launch of a not-ready app. | 554 // Test an attempt to launch of a not-ready app. |
552 bridge_service()->SetStopped(); | 555 bridge_service()->SetStopped(); |
(...skipping 15 matching lines...) Expand all Loading... |
568 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 571 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
569 | 572 |
570 // Simulate item activate. | 573 // Simulate item activate. |
571 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; | 574 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; |
572 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; | 575 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; |
573 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 576 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
574 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); | 577 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); |
575 ASSERT_NE(nullptr, item_first); | 578 ASSERT_NE(nullptr, item_first); |
576 ASSERT_NE(nullptr, item_last); | 579 ASSERT_NE(nullptr, item_last); |
577 item_first->Activate(0); | 580 item_first->Activate(0); |
| 581 app_instance()->WaitForIncomingMethodCall(); |
578 item_last->Activate(0); | 582 item_last->Activate(0); |
| 583 app_instance()->WaitForIncomingMethodCall(); |
579 item_first->Activate(0); | 584 item_first->Activate(0); |
| 585 app_instance()->WaitForIncomingMethodCall(); |
580 | 586 |
581 const ScopedVector<mojo::String>& launch_intents = | 587 const ScopedVector<mojo::String>& launch_intents = |
582 app_instance()->launch_intents(); | 588 app_instance()->launch_intents(); |
583 ASSERT_EQ(3u, launch_intents.size()); | 589 ASSERT_EQ(3u, launch_intents.size()); |
584 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[0]); | 590 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[0]); |
585 EXPECT_EQ(true, app_last.intent_uri == *launch_intents[1]); | 591 EXPECT_EQ(true, app_last.intent_uri == *launch_intents[1]); |
586 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[2]); | 592 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[2]); |
587 | 593 |
588 // Test an attempt to launch of a not-ready shortcut. | 594 // Test an attempt to launch of a not-ready shortcut. |
589 bridge_service()->SetStopped(); | 595 bridge_service()->SetStopped(); |
(...skipping 25 matching lines...) Expand all Loading... |
615 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); | 621 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); |
616 ASSERT_NE(nullptr, app_item); | 622 ASSERT_NE(nullptr, app_item); |
617 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 623 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
618 app_item->icon().GetRepresentation(scale); | 624 app_item->icon().GetRepresentation(scale); |
619 } | 625 } |
620 } | 626 } |
621 | 627 |
622 // Process pending tasks. | 628 // Process pending tasks. |
623 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 629 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
624 base::RunLoop().RunUntilIdle(); | 630 base::RunLoop().RunUntilIdle(); |
| 631 // Normally just one call to RunUntilIdle() suffices to make sure |
| 632 // all RequestAppIcon() calls are delivered, but on slower machines |
| 633 // (especially when running under Valgrind), they might not get |
| 634 // delivered on time. Wait for the remaining tasks individually. |
625 const size_t expected_size = scale_factors.size() * fake_apps().size(); | 635 const size_t expected_size = scale_factors.size() * fake_apps().size(); |
| 636 while (app_instance()->icon_requests().size() < expected_size) { |
| 637 app_instance()->WaitForIncomingMethodCall(); |
| 638 } |
626 | 639 |
627 // At this moment we should receive all requests for icon loading. | 640 // At this moment we should receive all requests for icon loading. |
628 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests = | 641 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests = |
629 app_instance()->icon_requests(); | 642 app_instance()->icon_requests(); |
630 EXPECT_EQ(expected_size, icon_requests.size()); | 643 EXPECT_EQ(expected_size, icon_requests.size()); |
631 std::map<std::string, uint32_t> app_masks; | 644 std::map<std::string, uint32_t> app_masks; |
632 for (size_t i = 0; i < icon_requests.size(); ++i) { | 645 for (size_t i = 0; i < icon_requests.size(); ++i) { |
633 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i]; | 646 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i]; |
634 const std::string id = ArcAppListPrefs::GetAppId( | 647 const std::string id = ArcAppListPrefs::GetAppId( |
635 icon_request->package_name(), icon_request->activity()); | 648 icon_request->package_name(), icon_request->activity()); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 EXPECT_FALSE(launcher3.app_launched()); | 928 EXPECT_FALSE(launcher3.app_launched()); |
916 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 929 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
917 | 930 |
918 EXPECT_EQ(0u, app_instance()->launch_requests().size()); | 931 EXPECT_EQ(0u, app_instance()->launch_requests().size()); |
919 | 932 |
920 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin(), | 933 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin(), |
921 fake_apps().begin() + 2); | 934 fake_apps().begin() + 2); |
922 app_instance()->SendRefreshAppList(apps); | 935 app_instance()->SendRefreshAppList(apps); |
923 | 936 |
924 EXPECT_TRUE(launcher1.app_launched()); | 937 EXPECT_TRUE(launcher1.app_launched()); |
| 938 app_instance()->WaitForIncomingMethodCall(); |
925 ASSERT_EQ(1u, app_instance()->launch_requests().size()); | 939 ASSERT_EQ(1u, app_instance()->launch_requests().size()); |
926 EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(app1)); | 940 EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(app1)); |
927 EXPECT_FALSE(launcher3.app_launched()); | 941 EXPECT_FALSE(launcher3.app_launched()); |
928 EXPECT_FALSE(prefs->HasObserver(&launcher1)); | 942 EXPECT_FALSE(prefs->HasObserver(&launcher1)); |
929 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 943 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
930 | 944 |
931 ArcAppLauncher launcher2(profile(), id2, true); | 945 ArcAppLauncher launcher2(profile(), id2, true); |
932 EXPECT_TRUE(launcher2.app_launched()); | 946 EXPECT_TRUE(launcher2.app_launched()); |
| 947 app_instance()->WaitForIncomingMethodCall(); |
933 EXPECT_FALSE(prefs->HasObserver(&launcher2)); | 948 EXPECT_FALSE(prefs->HasObserver(&launcher2)); |
934 ASSERT_EQ(2u, app_instance()->launch_requests().size()); | 949 ASSERT_EQ(2u, app_instance()->launch_requests().size()); |
935 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); | 950 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); |
936 } | 951 } |
OLD | NEW |