Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: components/arc/intent_helper/activity_icon_loader_unittest.cc

Issue 2034543003: Retry icon fetching after intent_helper is ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/arc/intent_helper/activity_icon_loader.h" 5 #include "components/arc/intent_helper/activity_icon_loader.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 gfx::Image()); 82 gfx::Image());
83 loader->AddIconToCacheForTesting(ActivityIconLoader::ActivityName("p1", "a0"), 83 loader->AddIconToCacheForTesting(ActivityIconLoader::ActivityName("p1", "a0"),
84 gfx::Image()); 84 gfx::Image());
85 85
86 // Check that GetActivityIcons() immediately calls OnIconsReady0() with all 86 // Check that GetActivityIcons() immediately calls OnIconsReady0() with all
87 // locally cached icons. 87 // locally cached icons.
88 std::vector<ActivityIconLoader::ActivityName> activities; 88 std::vector<ActivityIconLoader::ActivityName> activities;
89 activities.emplace_back("p0", "a0"); 89 activities.emplace_back("p0", "a0");
90 activities.emplace_back("p1", "a1"); 90 activities.emplace_back("p1", "a1");
91 activities.emplace_back("p1", "a0"); 91 activities.emplace_back("p1", "a0");
92 EXPECT_TRUE(loader->GetActivityIcons(activities, base::Bind(&OnIconsReady0))); 92 EXPECT_EQ(ActivityIconLoader::GetResult::SUCCEEDED_SYNC,
93 loader->GetActivityIcons(activities, base::Bind(&OnIconsReady0)));
93 94
94 // Test with different |activities|. 95 // Test with different |activities|.
95 activities.clear(); 96 activities.clear();
96 activities.emplace_back("p1", "a1"); 97 activities.emplace_back("p1", "a1");
97 EXPECT_TRUE(loader->GetActivityIcons(activities, base::Bind(&OnIconsReady1))); 98 EXPECT_EQ(ActivityIconLoader::GetResult::SUCCEEDED_SYNC,
99 loader->GetActivityIcons(activities, base::Bind(&OnIconsReady1)));
98 activities.clear(); 100 activities.clear();
101 EXPECT_EQ(ActivityIconLoader::GetResult::SUCCEEDED_SYNC,
102 loader->GetActivityIcons(activities, base::Bind(&OnIconsReady2)));
99 activities.emplace_back("p1", "a_unknown"); 103 activities.emplace_back("p1", "a_unknown");
100 EXPECT_TRUE(loader->GetActivityIcons(activities, base::Bind(&OnIconsReady2))); 104 EXPECT_EQ(ActivityIconLoader::GetResult::FAILED_ARC_NOT_SUPPORTED,
101 activities.clear(); 105 loader->GetActivityIcons(activities, base::Bind(&OnIconsReady2)));
102 EXPECT_TRUE(loader->GetActivityIcons(activities, base::Bind(&OnIconsReady2)));
103 } 106 }
104 107
105 // Tests if OnIconsResized updates the cache. 108 // Tests if OnIconsResized updates the cache.
106 TEST(ActivityIconLoaderTest, TestOnIconsResized) { 109 TEST(ActivityIconLoaderTest, TestOnIconsResized) {
107 scoped_refptr<ActivityIconLoader> loader(new ActivityIconLoader); 110 scoped_refptr<ActivityIconLoader> loader(new ActivityIconLoader);
108 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> activity_to_icons( 111 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> activity_to_icons(
109 new ActivityIconLoader::ActivityToIconsMap); 112 new ActivityIconLoader::ActivityToIconsMap);
110 activity_to_icons->insert( 113 activity_to_icons->insert(
111 std::make_pair(ActivityIconLoader::ActivityName("p0", "a0"), 114 std::make_pair(ActivityIconLoader::ActivityName("p0", "a0"),
112 ActivityIconLoader::Icons(gfx::Image(), gfx::Image()))); 115 ActivityIconLoader::Icons(gfx::Image(), gfx::Image())));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 ActivityIconLoader::ActivityName("p0", "a0"))); 153 ActivityIconLoader::ActivityName("p0", "a0")));
151 EXPECT_EQ(1U, loader->cached_icons_for_testing().count( 154 EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
152 ActivityIconLoader::ActivityName("p1", "a1"))); 155 ActivityIconLoader::ActivityName("p1", "a1")));
153 EXPECT_EQ(1U, loader->cached_icons_for_testing().count( 156 EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
154 ActivityIconLoader::ActivityName("p1", "a0"))); 157 ActivityIconLoader::ActivityName("p1", "a0")));
155 EXPECT_EQ(1U, loader->cached_icons_for_testing().count( 158 EXPECT_EQ(1U, loader->cached_icons_for_testing().count(
156 ActivityIconLoader::ActivityName("p2", "a2"))); 159 ActivityIconLoader::ActivityName("p2", "a2")));
157 } 160 }
158 161
159 } // namespace arc 162 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/intent_helper/activity_icon_loader.cc ('k') | components/arc/intent_helper/link_handler_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698