| Index: components/arc/intent_helper/activity_icon_loader_unittest.cc
|
| diff --git a/components/arc/intent_helper/activity_icon_loader_unittest.cc b/components/arc/intent_helper/activity_icon_loader_unittest.cc
|
| index 072be804867e1344afe7b85c326e458e9f61a455..586897e084ea706cea632fa037b4ec9b9e44b370 100644
|
| --- a/components/arc/intent_helper/activity_icon_loader_unittest.cc
|
| +++ b/components/arc/intent_helper/activity_icon_loader_unittest.cc
|
| @@ -9,11 +9,10 @@
|
| #include <vector>
|
|
|
| #include "base/bind.h"
|
| -#include "base/memory/ref_counted.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace arc {
|
| -
|
| +namespace internal {
|
| namespace {
|
|
|
| void OnIconsReady0(
|
| @@ -48,35 +47,33 @@ void OnIconsReady3(
|
| ActivityIconLoader::ActivityName("p2", "a2")));
|
| }
|
|
|
| -} // namespace
|
| -
|
| // Tests if InvalidateIcons properly cleans up the cache.
|
| TEST(ActivityIconLoaderTest, TestInvalidateIcons) {
|
| - scoped_refptr<ActivityIconLoader> loader(new ActivityIconLoader);
|
| - loader->AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p0", "a0"));
|
| - loader->AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p0", "a1"));
|
| - loader->AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p1", "a0"));
|
| - EXPECT_EQ(3U, loader->cached_icons_for_testing().size());
|
| + ActivityIconLoader loader;
|
| + loader.AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p0", "a0"));
|
| + loader.AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p0", "a1"));
|
| + loader.AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p1", "a0"));
|
| + EXPECT_EQ(3U, loader.cached_icons_for_testing().size());
|
|
|
| - loader->InvalidateIcons("p2"); // delete none.
|
| - EXPECT_EQ(3U, loader->cached_icons_for_testing().size());
|
| + loader.InvalidateIcons("p2"); // delete none.
|
| + EXPECT_EQ(3U, loader.cached_icons_for_testing().size());
|
|
|
| - loader->InvalidateIcons("p0"); // delete 2 entries.
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().size());
|
| + loader.InvalidateIcons("p0"); // delete 2 entries.
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().size());
|
|
|
| - loader->InvalidateIcons("p2"); // delete none.
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().size());
|
| + loader.InvalidateIcons("p2"); // delete none.
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().size());
|
|
|
| - loader->InvalidateIcons("p1"); // delete 1 entry.
|
| - EXPECT_EQ(0U, loader->cached_icons_for_testing().size());
|
| + loader.InvalidateIcons("p1"); // delete 1 entry.
|
| + EXPECT_EQ(0U, loader.cached_icons_for_testing().size());
|
| }
|
|
|
| // Tests if GetActivityIcons immediately returns cached icons.
|
| TEST(ActivityIconLoaderTest, TestGetActivityIcons) {
|
| - scoped_refptr<ActivityIconLoader> loader(new ActivityIconLoader);
|
| - loader->AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p0", "a0"));
|
| - loader->AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p1", "a1"));
|
| - loader->AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p1", "a0"));
|
| + ActivityIconLoader loader;
|
| + loader.AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p0", "a0"));
|
| + loader.AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p1", "a1"));
|
| + loader.AddCacheEntryForTesting(ActivityIconLoader::ActivityName("p1", "a0"));
|
|
|
| // Check that GetActivityIcons() immediately calls OnIconsReady0() with all
|
| // locally cached icons.
|
| @@ -85,24 +82,23 @@ TEST(ActivityIconLoaderTest, TestGetActivityIcons) {
|
| activities.emplace_back("p1", "a1");
|
| activities.emplace_back("p1", "a0");
|
| EXPECT_EQ(ActivityIconLoader::GetResult::SUCCEEDED_SYNC,
|
| - loader->GetActivityIcons(activities, base::Bind(&OnIconsReady0)));
|
| + loader.GetActivityIcons(activities, base::Bind(&OnIconsReady0)));
|
|
|
| // Test with different |activities|.
|
| activities.clear();
|
| activities.emplace_back("p1", "a1");
|
| EXPECT_EQ(ActivityIconLoader::GetResult::SUCCEEDED_SYNC,
|
| - loader->GetActivityIcons(activities, base::Bind(&OnIconsReady1)));
|
| + loader.GetActivityIcons(activities, base::Bind(&OnIconsReady1)));
|
| activities.clear();
|
| EXPECT_EQ(ActivityIconLoader::GetResult::SUCCEEDED_SYNC,
|
| - loader->GetActivityIcons(activities, base::Bind(&OnIconsReady2)));
|
| + loader.GetActivityIcons(activities, base::Bind(&OnIconsReady2)));
|
| activities.emplace_back("p1", "a_unknown");
|
| EXPECT_EQ(ActivityIconLoader::GetResult::FAILED_ARC_NOT_SUPPORTED,
|
| - loader->GetActivityIcons(activities, base::Bind(&OnIconsReady2)));
|
| + loader.GetActivityIcons(activities, base::Bind(&OnIconsReady2)));
|
| }
|
|
|
| // Tests if OnIconsResized updates the cache.
|
| TEST(ActivityIconLoaderTest, TestOnIconsResized) {
|
| - scoped_refptr<ActivityIconLoader> loader(new ActivityIconLoader);
|
| std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> activity_to_icons(
|
| new ActivityIconLoader::ActivityToIconsMap);
|
| activity_to_icons->insert(std::make_pair(
|
| @@ -119,15 +115,17 @@ TEST(ActivityIconLoaderTest, TestOnIconsResized) {
|
| ActivityIconLoader::ActivityName("p0", "a0"),
|
| ActivityIconLoader::Icons(gfx::Image(), gfx::Image(), nullptr)));
|
|
|
| + ActivityIconLoader loader;
|
| +
|
| // Call OnIconsResized() and check that the cache is properly updated.
|
| - loader->OnIconsResizedForTesting(base::Bind(&OnIconsReady0),
|
| - std::move(activity_to_icons));
|
| - EXPECT_EQ(3U, loader->cached_icons_for_testing().size());
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
|
| + loader.OnIconsResizedForTesting(base::Bind(&OnIconsReady0),
|
| + std::move(activity_to_icons));
|
| + EXPECT_EQ(3U, loader.cached_icons_for_testing().size());
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().count(
|
| ActivityIconLoader::ActivityName("p0", "a0")));
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().count(
|
| ActivityIconLoader::ActivityName("p1", "a1")));
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().count(
|
| ActivityIconLoader::ActivityName("p1", "a0")));
|
|
|
| // Call OnIconsResized() again to make sure that the second call does not
|
| @@ -141,17 +139,19 @@ TEST(ActivityIconLoaderTest, TestOnIconsResized) {
|
| activity_to_icons->insert(std::make_pair(
|
| ActivityIconLoader::ActivityName("p2", "a2"),
|
| ActivityIconLoader::Icons(gfx::Image(), gfx::Image(), nullptr)));
|
| - loader->OnIconsResizedForTesting(base::Bind(&OnIconsReady3),
|
| - std::move(activity_to_icons));
|
| - EXPECT_EQ(4U, loader->cached_icons_for_testing().size());
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
|
| + loader.OnIconsResizedForTesting(base::Bind(&OnIconsReady3),
|
| + std::move(activity_to_icons));
|
| + EXPECT_EQ(4U, loader.cached_icons_for_testing().size());
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().count(
|
| ActivityIconLoader::ActivityName("p0", "a0")));
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().count(
|
| ActivityIconLoader::ActivityName("p1", "a1")));
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().count(
|
| ActivityIconLoader::ActivityName("p1", "a0")));
|
| - EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
|
| + EXPECT_EQ(1U, loader.cached_icons_for_testing().count(
|
| ActivityIconLoader::ActivityName("p2", "a2")));
|
| }
|
|
|
| +} // namespace
|
| +} // namespace internal
|
| } // namespace arc
|
|
|