| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 class FakeAppIconLoaderDelegate : public AppIconLoaderDelegate { | 61 class FakeAppIconLoaderDelegate : public AppIconLoaderDelegate { |
| 62 public: | 62 public: |
| 63 FakeAppIconLoaderDelegate() = default; | 63 FakeAppIconLoaderDelegate() = default; |
| 64 ~FakeAppIconLoaderDelegate() override = default; | 64 ~FakeAppIconLoaderDelegate() override = default; |
| 65 | 65 |
| 66 void OnAppImageUpdated(const std::string& app_id, | 66 void OnAppImageUpdated(const std::string& app_id, |
| 67 const gfx::ImageSkia& image) override { | 67 const gfx::ImageSkia& image) override { |
| 68 app_id_ = app_id; | 68 app_id_ = app_id; |
| 69 image_ = image; | 69 image_ = image; |
| 70 ++update_image_cnt_; | 70 ++update_image_cnt_; |
| 71 if (update_image_cnt_ == expected_update_image_cnt_ && |
| 72 !icon_updated_callback_.is_null()) { |
| 73 base::ResetAndReturn(&icon_updated_callback_).Run(); |
| 74 } |
| 75 } |
| 76 |
| 77 void WaitForIconUpdates(size_t expected_updates) { |
| 78 base::RunLoop run_loop; |
| 79 expected_update_image_cnt_ = expected_updates + update_image_cnt_; |
| 80 icon_updated_callback_ = run_loop.QuitClosure(); |
| 81 run_loop.Run(); |
| 71 } | 82 } |
| 72 | 83 |
| 73 size_t update_image_cnt() const { return update_image_cnt_; } | 84 size_t update_image_cnt() const { return update_image_cnt_; } |
| 74 | 85 |
| 75 const std::string& app_id() const { return app_id_; } | 86 const std::string& app_id() const { return app_id_; } |
| 76 | 87 |
| 77 const gfx::ImageSkia& image() { return image_; } | 88 const gfx::ImageSkia& image() { return image_; } |
| 78 | 89 |
| 79 private: | 90 private: |
| 80 size_t update_image_cnt_ = 0; | 91 size_t update_image_cnt_ = 0; |
| 92 size_t expected_update_image_cnt_ = 0; |
| 81 std::string app_id_; | 93 std::string app_id_; |
| 82 gfx::ImageSkia image_; | 94 gfx::ImageSkia image_; |
| 95 base::OnceClosure icon_updated_callback_; |
| 83 | 96 |
| 84 DISALLOW_COPY_AND_ASSIGN(FakeAppIconLoaderDelegate); | 97 DISALLOW_COPY_AND_ASSIGN(FakeAppIconLoaderDelegate); |
| 85 }; | 98 }; |
| 86 | 99 |
| 87 void WaitForIconReady(ArcAppListPrefs* prefs, | 100 bool IsIconCreated(ArcAppListPrefs* prefs, |
| 88 const std::string& app_id, | 101 const std::string& app_id, |
| 89 ui::ScaleFactor scale_factor) { | 102 ui::ScaleFactor scale_factor) { |
| 103 return base::PathExists(prefs->GetIconPath(app_id, scale_factor)); |
| 104 } |
| 105 |
| 106 void WaitForIconCreation(ArcAppListPrefs* prefs, |
| 107 const std::string& app_id, |
| 108 ui::ScaleFactor scale_factor) { |
| 90 const base::FilePath icon_path = prefs->GetIconPath(app_id, scale_factor); | 109 const base::FilePath icon_path = prefs->GetIconPath(app_id, scale_factor); |
| 91 // Process pending tasks. This performs multiple thread hops, so we need | 110 // Process pending tasks. This performs multiple thread hops, so we need |
| 92 // to run it continuously until it is resolved. | 111 // to run it continuously until it is resolved. |
| 93 do { | 112 do { |
| 94 content::RunAllBlockingPoolTasksUntilIdle(); | 113 content::RunAllBlockingPoolTasksUntilIdle(); |
| 95 } while (!base::PathExists(icon_path)); | 114 } while (!base::PathExists(icon_path)); |
| 96 } | 115 } |
| 97 | 116 |
| 117 void WaitForIconUpdates(Profile* profile, |
| 118 const std::string& app_id, |
| 119 size_t expected_updates) { |
| 120 FakeAppIconLoaderDelegate delegate; |
| 121 ArcAppIconLoader icon_loader(profile, app_list::kListIconSize, &delegate); |
| 122 icon_loader.FetchImage(app_id); |
| 123 delegate.WaitForIconUpdates(expected_updates); |
| 124 } |
| 125 |
| 98 enum class ArcState { | 126 enum class ArcState { |
| 99 // By default, ARC is non-persistent and Play Store is unmanaged. | 127 // By default, ARC is non-persistent and Play Store is unmanaged. |
| 100 ARC_PLAY_STORE_UNMANAGED, | 128 ARC_PLAY_STORE_UNMANAGED, |
| 101 // ARC is persistent and Play Store is unmanaged | 129 // ARC is persistent and Play Store is unmanaged |
| 102 ARC_PERSISTENT_PLAY_STORE_UNMANAGED, | 130 ARC_PERSISTENT_PLAY_STORE_UNMANAGED, |
| 103 // ARC is non-persistent and Play Store is managed and enabled. | 131 // ARC is non-persistent and Play Store is managed and enabled. |
| 104 ARC_PLAY_STORE_MANAGED_AND_ENABLED, | 132 ARC_PLAY_STORE_MANAGED_AND_ENABLED, |
| 105 // ARC is non-persistent and Play Store is managed and disabled. | 133 // ARC is non-persistent and Play Store is managed and disabled. |
| 106 ARC_PLAY_STORE_MANAGED_AND_DISABLED, | 134 ARC_PLAY_STORE_MANAGED_AND_DISABLED, |
| 107 // ARC is persistent and Play Store is managed and enabled. | 135 // ARC is persistent and Play Store is managed and enabled. |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 const std::vector<ui::ScaleFactor>& scale_factors = | 867 const std::vector<ui::ScaleFactor>& scale_factors = |
| 840 ui::GetSupportedScaleFactors(); | 868 ui::GetSupportedScaleFactors(); |
| 841 for (auto& scale_factor : scale_factors) { | 869 for (auto& scale_factor : scale_factors) { |
| 842 expected_mask |= 1 << scale_factor; | 870 expected_mask |= 1 << scale_factor; |
| 843 for (auto& app : fake_apps()) { | 871 for (auto& app : fake_apps()) { |
| 844 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); | 872 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); |
| 845 ASSERT_NE(nullptr, app_item); | 873 ASSERT_NE(nullptr, app_item); |
| 846 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 874 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
| 847 app_item->icon().GetRepresentation(scale); | 875 app_item->icon().GetRepresentation(scale); |
| 848 | 876 |
| 849 // This does not result in an icon being loaded, so WaitForIconReady | 877 // This does not result in an icon being loaded, so WaitForIconUpdates |
| 850 // cannot be used. | 878 // cannot be used. |
| 851 content::RunAllBlockingPoolTasksUntilIdle(); | 879 content::RunAllBlockingPoolTasksUntilIdle(); |
| 852 } | 880 } |
| 853 } | 881 } |
| 854 | 882 |
| 855 const size_t expected_size = scale_factors.size() * fake_apps().size(); | 883 const size_t expected_size = scale_factors.size() * fake_apps().size(); |
| 856 | 884 |
| 857 // At this moment we should receive all requests for icon loading. | 885 // At this moment we should receive all requests for icon loading. |
| 858 const std::vector<std::unique_ptr<arc::FakeAppInstance::IconRequest>>& | 886 const std::vector<std::unique_ptr<arc::FakeAppInstance::IconRequest>>& |
| 859 icon_requests = app_instance()->icon_requests(); | 887 icon_requests = app_instance()->icon_requests(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 ASSERT_NE(nullptr, prefs); | 919 ASSERT_NE(nullptr, prefs); |
| 892 | 920 |
| 893 // Icons representations loading is done asynchronously and is started once | 921 // Icons representations loading is done asynchronously and is started once |
| 894 // the ArcAppItem is created. Wait for icons for all supported scales to be | 922 // the ArcAppItem is created. Wait for icons for all supported scales to be |
| 895 // loaded. | 923 // loaded. |
| 896 uint32_t expected_mask = 0; | 924 uint32_t expected_mask = 0; |
| 897 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(shortcut)); | 925 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(shortcut)); |
| 898 ASSERT_NE(nullptr, app_item); | 926 ASSERT_NE(nullptr, app_item); |
| 899 const std::vector<ui::ScaleFactor>& scale_factors = | 927 const std::vector<ui::ScaleFactor>& scale_factors = |
| 900 ui::GetSupportedScaleFactors(); | 928 ui::GetSupportedScaleFactors(); |
| 929 WaitForIconUpdates(profile_.get(), app_item->id(), scale_factors.size()); |
| 901 for (auto& scale_factor : scale_factors) { | 930 for (auto& scale_factor : scale_factors) { |
| 902 expected_mask |= 1 << scale_factor; | 931 expected_mask |= 1 << scale_factor; |
| 903 const base::FilePath icon_path = | 932 EXPECT_TRUE( |
| 904 prefs->GetIconPath(ArcAppTest::GetAppId(shortcut), scale_factor); | 933 IsIconCreated(prefs, ArcAppTest::GetAppId(shortcut), scale_factor)); |
| 905 WaitForIconReady(prefs, ArcAppTest::GetAppId(shortcut), scale_factor); | |
| 906 } | 934 } |
| 907 | 935 |
| 908 // At this moment we should receive all requests for icon loading. | 936 // At this moment we should receive all requests for icon loading. |
| 909 const size_t expected_size = scale_factors.size(); | 937 const size_t expected_size = scale_factors.size(); |
| 910 const std::vector<std::unique_ptr<arc::FakeAppInstance::ShortcutIconRequest>>& | 938 const std::vector<std::unique_ptr<arc::FakeAppInstance::ShortcutIconRequest>>& |
| 911 icon_requests = app_instance()->shortcut_icon_requests(); | 939 icon_requests = app_instance()->shortcut_icon_requests(); |
| 912 EXPECT_EQ(expected_size, icon_requests.size()); | 940 EXPECT_EQ(expected_size, icon_requests.size()); |
| 913 uint32_t app_mask = 0; | 941 uint32_t app_mask = 0; |
| 914 for (size_t i = 0; i < icon_requests.size(); ++i) { | 942 for (size_t i = 0; i < icon_requests.size(); ++i) { |
| 915 const arc::FakeAppInstance::ShortcutIconRequest* icon_request = | 943 const arc::FakeAppInstance::ShortcutIconRequest* icon_request = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 940 app_instance()->RefreshAppList(); | 968 app_instance()->RefreshAppList(); |
| 941 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 969 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
| 942 fake_apps().begin(), fake_apps().begin() + 1)); | 970 fake_apps().begin(), fake_apps().begin() + 1)); |
| 943 const arc::mojom::AppInfo& app = fake_apps()[0]; | 971 const arc::mojom::AppInfo& app = fake_apps()[0]; |
| 944 | 972 |
| 945 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 973 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 946 ASSERT_NE(nullptr, prefs); | 974 ASSERT_NE(nullptr, prefs); |
| 947 | 975 |
| 948 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; | 976 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; |
| 949 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 977 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
| 950 const base::FilePath icon_path = prefs->GetIconPath(ArcAppTest::GetAppId(app), | 978 const std::string app_id = ArcAppTest::GetAppId(app); |
| 951 scale_factor); | 979 const base::FilePath icon_path = prefs->GetIconPath(app_id, scale_factor); |
| 952 EXPECT_FALSE(base::PathExists(icon_path)); | 980 EXPECT_FALSE(IsIconCreated(prefs, app_id, scale_factor)); |
| 953 | 981 |
| 954 const ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); | 982 const ArcAppItem* app_item = FindArcItem(app_id); |
| 955 EXPECT_NE(nullptr, app_item); | 983 EXPECT_NE(nullptr, app_item); |
| 956 // This initiates async loading. | 984 // This initiates async loading. |
| 957 app_item->icon().GetRepresentation(scale); | 985 app_item->icon().GetRepresentation(scale); |
| 958 | 986 |
| 959 // Now send generated icon for the app. | 987 // Now send generated icon for the app. |
| 960 std::string png_data; | 988 std::string png_data; |
| 961 EXPECT_TRUE(app_instance()->GenerateAndSendIcon( | 989 EXPECT_TRUE(app_instance()->GenerateAndSendIcon( |
| 962 app, static_cast<arc::mojom::ScaleFactor>(scale_factor), &png_data)); | 990 app, static_cast<arc::mojom::ScaleFactor>(scale_factor), &png_data)); |
| 963 WaitForIconReady(prefs, ArcAppTest::GetAppId(app), scale_factor); | 991 WaitForIconUpdates(profile_.get(), app_id, 1); |
| 964 | 992 |
| 965 // Validate that icons are installed, have right content and icon is | 993 // Validate that icons are installed, have right content and icon is |
| 966 // refreshed for ARC app item. | 994 // refreshed for ARC app item. |
| 967 EXPECT_TRUE(base::PathExists(icon_path)); | 995 EXPECT_TRUE(IsIconCreated(prefs, app_id, scale_factor)); |
| 968 | 996 |
| 969 std::string icon_data; | 997 std::string icon_data; |
| 970 // Read the file from disk and compare with reference data. | 998 // Read the file from disk and compare with reference data. |
| 971 EXPECT_TRUE(base::ReadFileToString(icon_path, &icon_data)); | 999 EXPECT_TRUE(base::ReadFileToString(icon_path, &icon_data)); |
| 972 ASSERT_EQ(icon_data, png_data); | 1000 ASSERT_EQ(icon_data, png_data); |
| 973 } | 1001 } |
| 974 | 1002 |
| 975 TEST_P(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) { | 1003 TEST_P(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) { |
| 976 // Make sure we are on UI thread. | 1004 // Make sure we are on UI thread. |
| 977 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 1005 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 978 | 1006 |
| 979 app_instance()->RefreshAppList(); | 1007 app_instance()->RefreshAppList(); |
| 980 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 1008 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
| 981 fake_apps().begin(), fake_apps().begin() + 1)); | 1009 fake_apps().begin(), fake_apps().begin() + 1)); |
| 982 const arc::mojom::AppInfo& app = fake_apps()[0]; | 1010 const arc::mojom::AppInfo& app = fake_apps()[0]; |
| 983 | 1011 |
| 984 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1012 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 985 ASSERT_NE(nullptr, prefs); | 1013 ASSERT_NE(nullptr, prefs); |
| 986 | 1014 |
| 987 const std::string app_id = ArcAppTest::GetAppId(app); | 1015 const std::string app_id = ArcAppTest::GetAppId(app); |
| 988 const base::FilePath app_path = prefs->GetAppPath(app_id); | 1016 const base::FilePath app_path = prefs->GetAppPath(app_id); |
| 989 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; | 1017 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; |
| 990 | 1018 |
| 991 // No app folder by default. | 1019 // No app folder by default. |
| 992 base::RunLoop().RunUntilIdle(); | 1020 base::RunLoop().RunUntilIdle(); |
| 993 EXPECT_FALSE(base::PathExists(app_path)); | 1021 EXPECT_FALSE(IsIconCreated(prefs, app_id, scale_factor)); |
| 994 | 1022 |
| 995 // Now send generated icon for the app. | 1023 // Now send generated icon for the app. |
| 996 std::string png_data; | 1024 std::string png_data; |
| 997 EXPECT_TRUE(app_instance()->GenerateAndSendIcon( | 1025 EXPECT_TRUE(app_instance()->GenerateAndSendIcon( |
| 998 app, static_cast<arc::mojom::ScaleFactor>(scale_factor), &png_data)); | 1026 app, static_cast<arc::mojom::ScaleFactor>(scale_factor), &png_data)); |
| 999 WaitForIconReady(prefs, app_id, scale_factor); | 1027 WaitForIconUpdates(profile_.get(), app_id, 1); |
| 1000 EXPECT_TRUE(base::PathExists(app_path)); | 1028 EXPECT_TRUE(IsIconCreated(prefs, app_id, scale_factor)); |
| 1001 | 1029 |
| 1002 // Send empty app list. This will delete app and its folder. | 1030 // Send empty app list. This will delete app and its folder. |
| 1003 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); | 1031 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); |
| 1004 // This cannot be WaitForIconReady since it needs to wait until the icon is | |
| 1005 // removed, not added. | |
| 1006 // Process pending tasks. This performs multiple thread hops, so we need | 1032 // Process pending tasks. This performs multiple thread hops, so we need |
| 1007 // to run it continuously until it is resolved. | 1033 // to run it continuously until it is resolved. |
| 1008 do { | 1034 do { |
| 1009 content::RunAllBlockingPoolTasksUntilIdle(); | 1035 content::RunAllBlockingPoolTasksUntilIdle(); |
| 1010 } while (base::PathExists(app_path)); | 1036 } while (IsIconCreated(prefs, app_id, scale_factor)); |
| 1011 EXPECT_FALSE(base::PathExists(app_path)); | |
| 1012 } | 1037 } |
| 1013 | 1038 |
| 1014 TEST_P(ArcAppModelBuilderTest, LastLaunchTime) { | 1039 TEST_P(ArcAppModelBuilderTest, LastLaunchTime) { |
| 1015 // Make sure we are on UI thread. | 1040 // Make sure we are on UI thread. |
| 1016 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 1041 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 1017 ASSERT_GE(fake_apps().size(), 3U); | 1042 ASSERT_GE(fake_apps().size(), 3U); |
| 1018 app_instance()->RefreshAppList(); | 1043 app_instance()->RefreshAppList(); |
| 1019 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 1044 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
| 1020 fake_apps().begin(), fake_apps().begin() + 3)); | 1045 fake_apps().begin(), fake_apps().begin() + 3)); |
| 1021 const arc::mojom::AppInfo& app1 = fake_apps()[0]; | 1046 const arc::mojom::AppInfo& app1 = fake_apps()[0]; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 // Store number of requests generated during the App List item creation. Same | 1251 // Store number of requests generated during the App List item creation. Same |
| 1227 // request will not be re-sent without clearing the request record in | 1252 // request will not be re-sent without clearing the request record in |
| 1228 // ArcAppListPrefs. | 1253 // ArcAppListPrefs. |
| 1229 const size_t initial_icon_request_count = | 1254 const size_t initial_icon_request_count = |
| 1230 app_instance()->icon_requests().size(); | 1255 app_instance()->icon_requests().size(); |
| 1231 | 1256 |
| 1232 FakeAppIconLoaderDelegate delegate; | 1257 FakeAppIconLoaderDelegate delegate; |
| 1233 ArcAppIconLoader icon_loader(profile(), app_list::kListIconSize, &delegate); | 1258 ArcAppIconLoader icon_loader(profile(), app_list::kListIconSize, &delegate); |
| 1234 icon_loader.FetchImage(app_id); | 1259 icon_loader.FetchImage(app_id); |
| 1235 | 1260 |
| 1236 content::RunAllBlockingPoolTasksUntilIdle(); | 1261 // So far one updated of default icon is expected. |
| 1262 EXPECT_EQ(delegate.update_image_cnt(), 1U); |
| 1263 |
| 1237 // Although icon file is still missing, expect no new request sent to ARC as | 1264 // Although icon file is still missing, expect no new request sent to ARC as |
| 1238 // them are recorded in IconRequestRecord in ArcAppListPrefs. | 1265 // them are recorded in IconRequestRecord in ArcAppListPrefs. |
| 1239 EXPECT_EQ(app_instance()->icon_requests().size(), initial_icon_request_count); | 1266 EXPECT_EQ(app_instance()->icon_requests().size(), initial_icon_request_count); |
| 1240 // Validate default image. | 1267 // Validate default image. |
| 1241 ValidateIcon(delegate.image()); | 1268 ValidateIcon(delegate.image()); |
| 1242 | 1269 |
| 1243 MaybeRemoveIconRequestRecord(app_id); | 1270 MaybeRemoveIconRequestRecord(app_id); |
| 1244 | 1271 |
| 1245 // Install Bad image. | 1272 // Install Bad image. |
| 1246 const std::vector<ui::ScaleFactor>& scale_factors = | 1273 const std::vector<ui::ScaleFactor>& scale_factors = |
| 1247 ui::GetSupportedScaleFactors(); | 1274 ui::GetSupportedScaleFactors(); |
| 1248 ArcAppItem* app_item = FindArcItem(app_id); | 1275 ArcAppItem* app_item = FindArcItem(app_id); |
| 1249 for (auto& scale_factor : scale_factors) { | 1276 for (auto& scale_factor : scale_factors) { |
| 1250 app_instance()->GenerateAndSendBadIcon( | 1277 app_instance()->GenerateAndSendBadIcon( |
| 1251 app, static_cast<arc::mojom::ScaleFactor>(scale_factor)); | 1278 app, static_cast<arc::mojom::ScaleFactor>(scale_factor)); |
| 1252 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 1279 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
| 1253 // Force the icon to be loaded. | 1280 // Force the icon to be loaded. |
| 1254 app_item->icon().GetRepresentation(scale); | 1281 app_item->icon().GetRepresentation(scale); |
| 1255 WaitForIconReady(prefs, app_id, scale_factor); | 1282 WaitForIconCreation(prefs, app_id, scale_factor); |
| 1256 } | 1283 } |
| 1284 |
| 1257 // After clear request record related to |app_id|, when bad icon is installed, | 1285 // After clear request record related to |app_id|, when bad icon is installed, |
| 1258 // decoding failure will trigger re-sending new icon request to ARC. | 1286 // decoding failure will trigger re-sending new icon request to ARC. |
| 1259 EXPECT_TRUE(app_instance()->icon_requests().size() > | 1287 EXPECT_TRUE(app_instance()->icon_requests().size() > |
| 1260 initial_icon_request_count); | 1288 initial_icon_request_count); |
| 1261 for (size_t i = initial_icon_request_count; | 1289 for (size_t i = initial_icon_request_count; |
| 1262 i < app_instance()->icon_requests().size(); ++i) { | 1290 i < app_instance()->icon_requests().size(); ++i) { |
| 1263 const auto& request = app_instance()->icon_requests()[i]; | 1291 const auto& request = app_instance()->icon_requests()[i]; |
| 1264 EXPECT_TRUE(request->IsForApp(app)); | 1292 EXPECT_TRUE(request->IsForApp(app)); |
| 1265 } | 1293 } |
| 1294 |
| 1295 // Icon update is not expected because of bad icon. |
| 1296 EXPECT_EQ(delegate.update_image_cnt(), 1U); |
| 1266 } | 1297 } |
| 1267 | 1298 |
| 1268 // TODO(crbug.com/628425) -- reenable once this test is less flaky. | 1299 TEST_P(ArcAppModelBuilderTest, IconLoader) { |
| 1269 TEST_P(ArcAppModelBuilderTest, DISABLED_IconLoader) { | |
| 1270 const arc::mojom::AppInfo& app = fake_apps()[0]; | 1300 const arc::mojom::AppInfo& app = fake_apps()[0]; |
| 1271 const std::string app_id = ArcAppTest::GetAppId(app); | 1301 const std::string app_id = ArcAppTest::GetAppId(app); |
| 1272 | 1302 |
| 1273 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1303 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 1274 ASSERT_NE(nullptr, prefs); | 1304 ASSERT_NE(nullptr, prefs); |
| 1275 | 1305 |
| 1276 app_instance()->RefreshAppList(); | 1306 app_instance()->RefreshAppList(); |
| 1277 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 1307 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
| 1278 fake_apps().begin(), fake_apps().begin() + 1)); | 1308 fake_apps().begin(), fake_apps().begin() + 1)); |
| 1279 | 1309 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1292 const std::vector<ui::ScaleFactor>& scale_factors = | 1322 const std::vector<ui::ScaleFactor>& scale_factors = |
| 1293 ui::GetSupportedScaleFactors(); | 1323 ui::GetSupportedScaleFactors(); |
| 1294 ArcAppItem* app_item = FindArcItem(app_id); | 1324 ArcAppItem* app_item = FindArcItem(app_id); |
| 1295 for (auto& scale_factor : scale_factors) { | 1325 for (auto& scale_factor : scale_factors) { |
| 1296 std::string png_data; | 1326 std::string png_data; |
| 1297 EXPECT_TRUE(app_instance()->GenerateAndSendIcon( | 1327 EXPECT_TRUE(app_instance()->GenerateAndSendIcon( |
| 1298 app, static_cast<arc::mojom::ScaleFactor>(scale_factor), &png_data)); | 1328 app, static_cast<arc::mojom::ScaleFactor>(scale_factor), &png_data)); |
| 1299 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 1329 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
| 1300 // Force the icon to be loaded. | 1330 // Force the icon to be loaded. |
| 1301 app_item->icon().GetRepresentation(scale); | 1331 app_item->icon().GetRepresentation(scale); |
| 1302 WaitForIconReady(prefs, app_id, scale_factor); | |
| 1303 } | 1332 } |
| 1304 | 1333 |
| 1334 delegate.WaitForIconUpdates(scale_factors.size()); |
| 1335 |
| 1305 // Validate loaded image. | 1336 // Validate loaded image. |
| 1306 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); | 1337 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); |
| 1307 EXPECT_EQ(app_id, delegate.app_id()); | 1338 EXPECT_EQ(app_id, delegate.app_id()); |
| 1308 ValidateIcon(delegate.image()); | 1339 ValidateIcon(delegate.image()); |
| 1340 |
| 1341 // No more updates are expected. |
| 1342 base::RunLoop().RunUntilIdle(); |
| 1343 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); |
| 1309 } | 1344 } |
| 1310 | 1345 |
| 1311 TEST_P(ArcAppModelBuilderTest, AppLauncher) { | 1346 TEST_P(ArcAppModelBuilderTest, AppLauncher) { |
| 1312 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile()); | 1347 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile()); |
| 1313 ASSERT_NE(nullptr, prefs); | 1348 ASSERT_NE(nullptr, prefs); |
| 1314 | 1349 |
| 1315 // App1 is called in deferred mode, after refreshing apps. | 1350 // App1 is called in deferred mode, after refreshing apps. |
| 1316 // App2 is never called since app is not avaialble. | 1351 // App2 is never called since app is not avaialble. |
| 1317 // App3 is never called immediately because app is available already. | 1352 // App3 is never called immediately because app is available already. |
| 1318 const arc::mojom::AppInfo& app1 = fake_apps()[0]; | 1353 const arc::mojom::AppInfo& app1 = fake_apps()[0]; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 ::testing::ValuesIn(kUnmanagedArcStates)); | 1667 ::testing::ValuesIn(kUnmanagedArcStates)); |
| 1633 INSTANTIATE_TEST_CASE_P(, | 1668 INSTANTIATE_TEST_CASE_P(, |
| 1634 ArcDefaulAppForManagedUserTest, | 1669 ArcDefaulAppForManagedUserTest, |
| 1635 ::testing::ValuesIn(kManagedArcStates)); | 1670 ::testing::ValuesIn(kManagedArcStates)); |
| 1636 INSTANTIATE_TEST_CASE_P(, | 1671 INSTANTIATE_TEST_CASE_P(, |
| 1637 ArcPlayStoreAppTest, | 1672 ArcPlayStoreAppTest, |
| 1638 ::testing::ValuesIn(kUnmanagedArcStates)); | 1673 ::testing::ValuesIn(kUnmanagedArcStates)); |
| 1639 INSTANTIATE_TEST_CASE_P(, | 1674 INSTANTIATE_TEST_CASE_P(, |
| 1640 ArcAppModelBuilderRecreate, | 1675 ArcAppModelBuilderRecreate, |
| 1641 ::testing::ValuesIn(kUnmanagedArcStates)); | 1676 ::testing::ValuesIn(kUnmanagedArcStates)); |
| OLD | NEW |