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(); | |
542 item_last->Activate(0); | 541 item_last->Activate(0); |
543 app_instance()->WaitForIncomingMethodCall(); | |
544 item_first->Activate(0); | 542 item_first->Activate(0); |
545 app_instance()->WaitForIncomingMethodCall(); | |
546 | 543 |
547 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = | 544 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = |
548 app_instance()->launch_requests(); | 545 app_instance()->launch_requests(); |
549 ASSERT_EQ(3u, launch_requests.size()); | 546 ASSERT_EQ(3u, launch_requests.size()); |
550 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_first)); | 547 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_first)); |
551 EXPECT_EQ(true, launch_requests[1]->IsForApp(app_last)); | 548 EXPECT_EQ(true, launch_requests[1]->IsForApp(app_last)); |
552 EXPECT_EQ(true, launch_requests[2]->IsForApp(app_first)); | 549 EXPECT_EQ(true, launch_requests[2]->IsForApp(app_first)); |
553 | 550 |
554 // Test an attempt to launch of a not-ready app. | 551 // Test an attempt to launch of a not-ready app. |
555 bridge_service()->SetStopped(); | 552 bridge_service()->SetStopped(); |
(...skipping 15 matching lines...) Expand all Loading... |
571 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 568 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
572 | 569 |
573 // Simulate item activate. | 570 // Simulate item activate. |
574 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; | 571 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; |
575 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; | 572 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; |
576 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 573 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
577 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); | 574 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); |
578 ASSERT_NE(nullptr, item_first); | 575 ASSERT_NE(nullptr, item_first); |
579 ASSERT_NE(nullptr, item_last); | 576 ASSERT_NE(nullptr, item_last); |
580 item_first->Activate(0); | 577 item_first->Activate(0); |
581 app_instance()->WaitForIncomingMethodCall(); | |
582 item_last->Activate(0); | 578 item_last->Activate(0); |
583 app_instance()->WaitForIncomingMethodCall(); | |
584 item_first->Activate(0); | 579 item_first->Activate(0); |
585 app_instance()->WaitForIncomingMethodCall(); | |
586 | 580 |
587 const ScopedVector<mojo::String>& launch_intents = | 581 const ScopedVector<mojo::String>& launch_intents = |
588 app_instance()->launch_intents(); | 582 app_instance()->launch_intents(); |
589 ASSERT_EQ(3u, launch_intents.size()); | 583 ASSERT_EQ(3u, launch_intents.size()); |
590 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[0]); | 584 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[0]); |
591 EXPECT_EQ(true, app_last.intent_uri == *launch_intents[1]); | 585 EXPECT_EQ(true, app_last.intent_uri == *launch_intents[1]); |
592 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[2]); | 586 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[2]); |
593 | 587 |
594 // Test an attempt to launch of a not-ready shortcut. | 588 // Test an attempt to launch of a not-ready shortcut. |
595 bridge_service()->SetStopped(); | 589 bridge_service()->SetStopped(); |
(...skipping 25 matching lines...) Expand all Loading... |
621 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); | 615 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); |
622 ASSERT_NE(nullptr, app_item); | 616 ASSERT_NE(nullptr, app_item); |
623 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 617 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
624 app_item->icon().GetRepresentation(scale); | 618 app_item->icon().GetRepresentation(scale); |
625 } | 619 } |
626 } | 620 } |
627 | 621 |
628 // Process pending tasks. | 622 // Process pending tasks. |
629 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 623 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
630 base::RunLoop().RunUntilIdle(); | 624 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. | |
635 const size_t expected_size = scale_factors.size() * fake_apps().size(); | 625 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 } | |
639 | 626 |
640 // At this moment we should receive all requests for icon loading. | 627 // At this moment we should receive all requests for icon loading. |
641 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests = | 628 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests = |
642 app_instance()->icon_requests(); | 629 app_instance()->icon_requests(); |
643 EXPECT_EQ(expected_size, icon_requests.size()); | 630 EXPECT_EQ(expected_size, icon_requests.size()); |
644 std::map<std::string, uint32_t> app_masks; | 631 std::map<std::string, uint32_t> app_masks; |
645 for (size_t i = 0; i < icon_requests.size(); ++i) { | 632 for (size_t i = 0; i < icon_requests.size(); ++i) { |
646 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i]; | 633 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i]; |
647 const std::string id = ArcAppListPrefs::GetAppId( | 634 const std::string id = ArcAppListPrefs::GetAppId( |
648 icon_request->package_name(), icon_request->activity()); | 635 icon_request->package_name(), icon_request->activity()); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 EXPECT_FALSE(launcher3.app_launched()); | 915 EXPECT_FALSE(launcher3.app_launched()); |
929 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 916 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
930 | 917 |
931 EXPECT_EQ(0u, app_instance()->launch_requests().size()); | 918 EXPECT_EQ(0u, app_instance()->launch_requests().size()); |
932 | 919 |
933 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin(), | 920 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin(), |
934 fake_apps().begin() + 2); | 921 fake_apps().begin() + 2); |
935 app_instance()->SendRefreshAppList(apps); | 922 app_instance()->SendRefreshAppList(apps); |
936 | 923 |
937 EXPECT_TRUE(launcher1.app_launched()); | 924 EXPECT_TRUE(launcher1.app_launched()); |
938 app_instance()->WaitForIncomingMethodCall(); | |
939 ASSERT_EQ(1u, app_instance()->launch_requests().size()); | 925 ASSERT_EQ(1u, app_instance()->launch_requests().size()); |
940 EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(app1)); | 926 EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(app1)); |
941 EXPECT_FALSE(launcher3.app_launched()); | 927 EXPECT_FALSE(launcher3.app_launched()); |
942 EXPECT_FALSE(prefs->HasObserver(&launcher1)); | 928 EXPECT_FALSE(prefs->HasObserver(&launcher1)); |
943 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 929 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
944 | 930 |
945 ArcAppLauncher launcher2(profile(), id2, true); | 931 ArcAppLauncher launcher2(profile(), id2, true); |
946 EXPECT_TRUE(launcher2.app_launched()); | 932 EXPECT_TRUE(launcher2.app_launched()); |
947 app_instance()->WaitForIncomingMethodCall(); | |
948 EXPECT_FALSE(prefs->HasObserver(&launcher2)); | 933 EXPECT_FALSE(prefs->HasObserver(&launcher2)); |
949 ASSERT_EQ(2u, app_instance()->launch_requests().size()); | 934 ASSERT_EQ(2u, app_instance()->launch_requests().size()); |
950 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); | 935 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); |
951 } | 936 } |
OLD | NEW |