| 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 <memory> | 10 #include <memory> |
| (...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 arc::ArcAppShelfId("arc_test_shelf_group", app_id).ToString(); | 1192 arc::ArcAppShelfId("arc_test_shelf_group", app_id).ToString(); |
| 1193 const std::string id_shortcut_absent = | 1193 const std::string id_shortcut_absent = |
| 1194 arc::ArcAppShelfId("arc_test_shelf_group_absent", app_id).ToString(); | 1194 arc::ArcAppShelfId("arc_test_shelf_group_absent", app_id).ToString(); |
| 1195 | 1195 |
| 1196 FakeAppIconLoaderDelegate delegate; | 1196 FakeAppIconLoaderDelegate delegate; |
| 1197 ArcAppIconLoader icon_loader(profile(), app_list::kListIconSize, &delegate); | 1197 ArcAppIconLoader icon_loader(profile(), app_list::kListIconSize, &delegate); |
| 1198 EXPECT_EQ(0UL, delegate.update_image_cnt()); | 1198 EXPECT_EQ(0UL, delegate.update_image_cnt()); |
| 1199 | 1199 |
| 1200 // Shortcut exists, icon is requested from shortcut. | 1200 // Shortcut exists, icon is requested from shortcut. |
| 1201 icon_loader.FetchImage(id_shortcut_exist); | 1201 icon_loader.FetchImage(id_shortcut_exist); |
| 1202 EXPECT_EQ(1UL, delegate.update_image_cnt()); | 1202 // Icon was sent on request and loader should be updated. |
| 1203 delegate.WaitForIconUpdates(ui::GetSupportedScaleFactors().size()); |
| 1203 EXPECT_EQ(id_shortcut_exist, delegate.app_id()); | 1204 EXPECT_EQ(id_shortcut_exist, delegate.app_id()); |
| 1205 |
| 1204 content::RunAllBlockingPoolTasksUntilIdle(); | 1206 content::RunAllBlockingPoolTasksUntilIdle(); |
| 1205 const size_t shortcut_request_cnt = | 1207 const size_t shortcut_request_cnt = |
| 1206 app_instance()->shortcut_icon_requests().size(); | 1208 app_instance()->shortcut_icon_requests().size(); |
| 1207 EXPECT_NE(0U, shortcut_request_cnt); | 1209 EXPECT_NE(0U, shortcut_request_cnt); |
| 1208 EXPECT_EQ(initial_icon_request_count, app_instance()->icon_requests().size()); | 1210 EXPECT_EQ(initial_icon_request_count, app_instance()->icon_requests().size()); |
| 1209 for (const auto& request : app_instance()->shortcut_icon_requests()) { | 1211 for (const auto& request : app_instance()->shortcut_icon_requests()) |
| 1210 EXPECT_EQ(shortcuts[0].icon_resource_id, request->icon_resource_id()); | 1212 EXPECT_EQ(shortcuts[0].icon_resource_id, request->icon_resource_id()); |
| 1211 } | |
| 1212 | 1213 |
| 1213 // Fallback when shortcut is not found for shelf group id, use app id instead. | 1214 // Fallback when shortcut is not found for shelf group id, use app id instead. |
| 1214 // Remove the IconRequestRecord for |app_id| to observe the icon request for | 1215 // Remove the IconRequestRecord for |app_id| to observe the icon request for |
| 1215 // |app_id| is re-sent. | 1216 // |app_id| is re-sent. |
| 1217 const size_t update_image_count_before = delegate.update_image_cnt(); |
| 1216 MaybeRemoveIconRequestRecord(app_id); | 1218 MaybeRemoveIconRequestRecord(app_id); |
| 1217 icon_loader.FetchImage(id_shortcut_absent); | 1219 icon_loader.FetchImage(id_shortcut_absent); |
| 1218 EXPECT_EQ(2UL, delegate.update_image_cnt()); | 1220 // Expected default update. |
| 1221 EXPECT_EQ(update_image_count_before + 1, delegate.update_image_cnt()); |
| 1219 content::RunAllBlockingPoolTasksUntilIdle(); | 1222 content::RunAllBlockingPoolTasksUntilIdle(); |
| 1220 EXPECT_TRUE(app_instance()->icon_requests().size() > | 1223 EXPECT_TRUE(app_instance()->icon_requests().size() > |
| 1221 initial_icon_request_count); | 1224 initial_icon_request_count); |
| 1222 EXPECT_EQ(shortcut_request_cnt, | 1225 EXPECT_EQ(shortcut_request_cnt, |
| 1223 app_instance()->shortcut_icon_requests().size()); | 1226 app_instance()->shortcut_icon_requests().size()); |
| 1224 for (size_t i = initial_icon_request_count; | 1227 for (size_t i = initial_icon_request_count; |
| 1225 i < app_instance()->icon_requests().size(); ++i) { | 1228 i < app_instance()->icon_requests().size(); ++i) { |
| 1226 const auto& request = app_instance()->icon_requests()[i]; | 1229 const auto& request = app_instance()->icon_requests()[i]; |
| 1227 EXPECT_TRUE(request->IsForApp(app)); | 1230 EXPECT_TRUE(request->IsForApp(app)); |
| 1228 } | 1231 } |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 ::testing::ValuesIn(kUnmanagedArcStates)); | 1728 ::testing::ValuesIn(kUnmanagedArcStates)); |
| 1726 INSTANTIATE_TEST_CASE_P(, | 1729 INSTANTIATE_TEST_CASE_P(, |
| 1727 ArcDefaulAppForManagedUserTest, | 1730 ArcDefaulAppForManagedUserTest, |
| 1728 ::testing::ValuesIn(kManagedArcStates)); | 1731 ::testing::ValuesIn(kManagedArcStates)); |
| 1729 INSTANTIATE_TEST_CASE_P(, | 1732 INSTANTIATE_TEST_CASE_P(, |
| 1730 ArcPlayStoreAppTest, | 1733 ArcPlayStoreAppTest, |
| 1731 ::testing::ValuesIn(kUnmanagedArcStates)); | 1734 ::testing::ValuesIn(kUnmanagedArcStates)); |
| 1732 INSTANTIATE_TEST_CASE_P(, | 1735 INSTANTIATE_TEST_CASE_P(, |
| 1733 ArcAppModelBuilderRecreate, | 1736 ArcAppModelBuilderRecreate, |
| 1734 ::testing::ValuesIn(kUnmanagedArcStates)); | 1737 ::testing::ValuesIn(kUnmanagedArcStates)); |
| OLD | NEW |