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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 app_instance()->SendRefreshAppList(fake_apps()); | 546 app_instance()->SendRefreshAppList(fake_apps()); |
547 | 547 |
548 // Simulate item activate. | 548 // Simulate item activate. |
549 const arc::mojom::AppInfo& app_first = fake_apps()[0]; | 549 const arc::mojom::AppInfo& app_first = fake_apps()[0]; |
550 const arc::mojom::AppInfo& app_last = fake_apps()[0]; | 550 const arc::mojom::AppInfo& app_last = fake_apps()[0]; |
551 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 551 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
552 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); | 552 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); |
553 ASSERT_NE(nullptr, item_first); | 553 ASSERT_NE(nullptr, item_first); |
554 ASSERT_NE(nullptr, item_last); | 554 ASSERT_NE(nullptr, item_last); |
555 item_first->Activate(0); | 555 item_first->Activate(0); |
556 app_instance()->WaitForIncomingMethodCall(); | |
557 item_last->Activate(0); | 556 item_last->Activate(0); |
558 app_instance()->WaitForIncomingMethodCall(); | |
559 item_first->Activate(0); | 557 item_first->Activate(0); |
560 app_instance()->WaitForIncomingMethodCall(); | |
561 | 558 |
562 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = | 559 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = |
563 app_instance()->launch_requests(); | 560 app_instance()->launch_requests(); |
564 ASSERT_EQ(3u, launch_requests.size()); | 561 ASSERT_EQ(3u, launch_requests.size()); |
565 EXPECT_TRUE(launch_requests[0]->IsForApp(app_first)); | 562 EXPECT_TRUE(launch_requests[0]->IsForApp(app_first)); |
566 EXPECT_TRUE(launch_requests[1]->IsForApp(app_last)); | 563 EXPECT_TRUE(launch_requests[1]->IsForApp(app_last)); |
567 EXPECT_TRUE(launch_requests[2]->IsForApp(app_first)); | 564 EXPECT_TRUE(launch_requests[2]->IsForApp(app_first)); |
568 | 565 |
569 // Test an attempt to launch of a not-ready app. | 566 // Test an attempt to launch of a not-ready app. |
570 bridge_service()->SetStopped(); | 567 bridge_service()->SetStopped(); |
(...skipping 15 matching lines...) Expand all Loading... |
586 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 583 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
587 | 584 |
588 // Simulate item activate. | 585 // Simulate item activate. |
589 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; | 586 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; |
590 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; | 587 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; |
591 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 588 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
592 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); | 589 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); |
593 ASSERT_NE(nullptr, item_first); | 590 ASSERT_NE(nullptr, item_first); |
594 ASSERT_NE(nullptr, item_last); | 591 ASSERT_NE(nullptr, item_last); |
595 item_first->Activate(0); | 592 item_first->Activate(0); |
596 app_instance()->WaitForIncomingMethodCall(); | |
597 item_last->Activate(0); | 593 item_last->Activate(0); |
598 app_instance()->WaitForIncomingMethodCall(); | |
599 item_first->Activate(0); | 594 item_first->Activate(0); |
600 app_instance()->WaitForIncomingMethodCall(); | |
601 | 595 |
602 const ScopedVector<mojo::String>& launch_intents = | 596 const ScopedVector<mojo::String>& launch_intents = |
603 app_instance()->launch_intents(); | 597 app_instance()->launch_intents(); |
604 ASSERT_EQ(3u, launch_intents.size()); | 598 ASSERT_EQ(3u, launch_intents.size()); |
605 EXPECT_EQ(app_first.intent_uri, *launch_intents[0]); | 599 EXPECT_EQ(app_first.intent_uri, *launch_intents[0]); |
606 EXPECT_EQ(app_last.intent_uri, *launch_intents[1]); | 600 EXPECT_EQ(app_last.intent_uri, *launch_intents[1]); |
607 EXPECT_EQ(app_first.intent_uri, *launch_intents[2]); | 601 EXPECT_EQ(app_first.intent_uri, *launch_intents[2]); |
608 | 602 |
609 // Test an attempt to launch of a not-ready shortcut. | 603 // Test an attempt to launch of a not-ready shortcut. |
610 bridge_service()->SetStopped(); | 604 bridge_service()->SetStopped(); |
(...skipping 27 matching lines...) Expand all Loading... |
638 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 632 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
639 app_item->icon().GetRepresentation(scale); | 633 app_item->icon().GetRepresentation(scale); |
640 | 634 |
641 // This does not result in an icon being loaded, so WaitForIconReady | 635 // This does not result in an icon being loaded, so WaitForIconReady |
642 // cannot be used. | 636 // cannot be used. |
643 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 637 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
644 base::RunLoop().RunUntilIdle(); | 638 base::RunLoop().RunUntilIdle(); |
645 } | 639 } |
646 } | 640 } |
647 | 641 |
648 // Normally just one call to RunUntilIdle() suffices to make sure | |
649 // all RequestAppIcon() calls are delivered, but on slower machines | |
650 // (especially when running under Valgrind), they might not get | |
651 // delivered on time. Wait for the remaining tasks individually. | |
652 const size_t expected_size = scale_factors.size() * fake_apps().size(); | 642 const size_t expected_size = scale_factors.size() * fake_apps().size(); |
653 while (app_instance()->icon_requests().size() < expected_size) { | |
654 app_instance()->WaitForIncomingMethodCall(); | |
655 } | |
656 | 643 |
657 // At this moment we should receive all requests for icon loading. | 644 // At this moment we should receive all requests for icon loading. |
658 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests = | 645 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests = |
659 app_instance()->icon_requests(); | 646 app_instance()->icon_requests(); |
660 EXPECT_EQ(expected_size, icon_requests.size()); | 647 EXPECT_EQ(expected_size, icon_requests.size()); |
661 std::map<std::string, uint32_t> app_masks; | 648 std::map<std::string, uint32_t> app_masks; |
662 for (size_t i = 0; i < icon_requests.size(); ++i) { | 649 for (size_t i = 0; i < icon_requests.size(); ++i) { |
663 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i]; | 650 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i]; |
664 const std::string id = ArcAppListPrefs::GetAppId( | 651 const std::string id = ArcAppListPrefs::GetAppId( |
665 icon_request->package_name(), icon_request->activity()); | 652 icon_request->package_name(), icon_request->activity()); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 EXPECT_FALSE(launcher3.app_launched()); | 920 EXPECT_FALSE(launcher3.app_launched()); |
934 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 921 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
935 | 922 |
936 EXPECT_EQ(0u, app_instance()->launch_requests().size()); | 923 EXPECT_EQ(0u, app_instance()->launch_requests().size()); |
937 | 924 |
938 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin(), | 925 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin(), |
939 fake_apps().begin() + 2); | 926 fake_apps().begin() + 2); |
940 app_instance()->SendRefreshAppList(apps); | 927 app_instance()->SendRefreshAppList(apps); |
941 | 928 |
942 EXPECT_TRUE(launcher1.app_launched()); | 929 EXPECT_TRUE(launcher1.app_launched()); |
943 app_instance()->WaitForIncomingMethodCall(); | |
944 ASSERT_EQ(1u, app_instance()->launch_requests().size()); | 930 ASSERT_EQ(1u, app_instance()->launch_requests().size()); |
945 EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(app1)); | 931 EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(app1)); |
946 EXPECT_FALSE(launcher3.app_launched()); | 932 EXPECT_FALSE(launcher3.app_launched()); |
947 EXPECT_FALSE(prefs->HasObserver(&launcher1)); | 933 EXPECT_FALSE(prefs->HasObserver(&launcher1)); |
948 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 934 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
949 | 935 |
950 ArcAppLauncher launcher2(profile(), id2, true); | 936 ArcAppLauncher launcher2(profile(), id2, true); |
951 EXPECT_TRUE(launcher2.app_launched()); | 937 EXPECT_TRUE(launcher2.app_launched()); |
952 app_instance()->WaitForIncomingMethodCall(); | |
953 EXPECT_FALSE(prefs->HasObserver(&launcher2)); | 938 EXPECT_FALSE(prefs->HasObserver(&launcher2)); |
954 ASSERT_EQ(2u, app_instance()->launch_requests().size()); | 939 ASSERT_EQ(2u, app_instance()->launch_requests().size()); |
955 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); | 940 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); |
956 } | 941 } |
OLD | NEW |