|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be
|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
| 5 | +#include <cstddef> |
5 | 6 | #include <memory>
|
6 | 7 | #include <utility>
|
7 | 8 | #include <vector>
|
|
26 | 27 | #include "chrome/browser/web_applications/web_app_install_info.h"
|
27 | 28 | #include "chrome/browser/web_applications/web_app_install_params.h"
|
28 | 29 | #include "chrome/browser/web_applications/web_app_provider.h"
|
| 30 | +#include "chrome/browser/web_applications/web_app_registry_update.h" |
29 | 31 | #include "chrome/common/chrome_features.h"
|
30 | 32 | #include "components/webapps/browser/install_result_code.h"
|
31 | 33 | #include "testing/gtest/include/gtest/gtest.h"
|
@@ -242,15 +244,18 @@ TEST_P(ShortcutMenuHandlingSubManagerConfigureTest, TestConfigure) {
|
242 | 244 | testing::Eq(base::StrCat(
|
243 | 245 | {kWebAppUrl.spec(), base::NumberToString(menu_index)})));
|
244 | 246 |
|
245 |
| - EXPECT_TRUE(os_integration_state.shortcut_menus() |
246 |
| - .shortcut_menu_info(menu_index) |
247 |
| - .icon_data_any_size() == num_sizes); |
248 |
| - EXPECT_TRUE(os_integration_state.shortcut_menus() |
249 |
| - .shortcut_menu_info(menu_index) |
250 |
| - .icon_data_maskable_size() == num_sizes); |
251 |
| - EXPECT_TRUE(os_integration_state.shortcut_menus() |
252 |
| - .shortcut_menu_info(menu_index) |
253 |
| - .icon_data_monochrome_size() == num_sizes); |
| 247 | + EXPECT_EQ(os_integration_state.shortcut_menus() |
| 248 | + .shortcut_menu_info(menu_index) |
| 249 | + .icon_data_any_size(), |
| 250 | + num_sizes); |
| 251 | + EXPECT_EQ(os_integration_state.shortcut_menus() |
| 252 | + .shortcut_menu_info(menu_index) |
| 253 | + .icon_data_maskable_size(), |
| 254 | + num_sizes); |
| 255 | + EXPECT_EQ(os_integration_state.shortcut_menus() |
| 256 | + .shortcut_menu_info(menu_index) |
| 257 | + .icon_data_monochrome_size(), |
| 258 | + num_sizes); |
254 | 259 |
|
255 | 260 | for (int size_index = 0; size_index < num_sizes; size_index++) {
|
256 | 261 | EXPECT_TRUE(os_integration_state.shortcut_menus()
|
@@ -284,6 +289,70 @@ TEST_P(ShortcutMenuHandlingSubManagerConfigureTest, TestConfigure) {
|
284 | 289 | }
|
285 | 290 | }
|
286 | 291 |
|
| 292 | +// This tests our handling of https://crbug.com/1427444. |
| 293 | +TEST_P(ShortcutMenuHandlingSubManagerConfigureTest, NoDownloadedIcons_1427444) { |
| 294 | + const int num_menu_items = 2; |
| 295 | + |
| 296 | + const std::vector<int> sizes = {icon_size::k64, icon_size::k128}; |
| 297 | + const std::vector<SkColor> colors = {SK_ColorRED, SK_ColorRED}; |
| 298 | + const AppId& app_id = InstallWebAppWithShortcutMenuIcons( |
| 299 | + MakeIconBitmaps({{IconPurpose::ANY, sizes, colors}, |
| 300 | + {IconPurpose::MASKABLE, sizes, colors}, |
| 301 | + {IconPurpose::MONOCHROME, sizes, colors}}, |
| 302 | + num_menu_items)); |
| 303 | + // Remove the downloaded icons & resync os integration. |
| 304 | + { |
| 305 | + ScopedRegistryUpdate remove_downloaded(&provider().sync_bridge_unsafe()); |
| 306 | + remove_downloaded->UpdateApp(app_id)->SetDownloadedShortcutsMenuIconsSizes( |
| 307 | + {}); |
| 308 | + } |
| 309 | + if (AreOsIntegrationSubManagersEnabled()) { |
| 310 | + base::test::TestFuture<void> future; |
| 311 | + provider().scheduler().SynchronizeOsIntegration(app_id, |
| 312 | + future.GetCallback()); |
| 313 | + ASSERT_TRUE(future.Wait()); |
| 314 | + } |
| 315 | + |
| 316 | + auto state = |
| 317 | + provider().registrar_unsafe().GetAppCurrentOsIntegrationState(app_id); |
| 318 | + ASSERT_TRUE(state.has_value()); |
| 319 | + const proto::WebAppOsIntegrationState& os_integration_state = state.value(); |
| 320 | + if (AreOsIntegrationSubManagersEnabled()) { |
| 321 | + EXPECT_TRUE( |
| 322 | + os_integration_state.shortcut_menus().shortcut_menu_info_size() == |
| 323 | + num_menu_items); |
| 324 | + |
| 325 | + for (int menu_index = 0; menu_index < num_menu_items; menu_index++) { |
| 326 | + EXPECT_THAT(os_integration_state.shortcut_menus() |
| 327 | + .shortcut_menu_info(menu_index) |
| 328 | + .shortcut_name(), |
| 329 | + testing::Eq(base::StrCat( |
| 330 | + {"shortcut_name", base::NumberToString(menu_index)}))); |
| 331 | + |
| 332 | + EXPECT_THAT(os_integration_state.shortcut_menus() |
| 333 | + .shortcut_menu_info(menu_index) |
| 334 | + .shortcut_launch_url(), |
| 335 | + testing::Eq(base::StrCat( |
| 336 | + {kWebAppUrl.spec(), base::NumberToString(menu_index)}))); |
| 337 | + |
| 338 | + EXPECT_EQ(os_integration_state.shortcut_menus() |
| 339 | + .shortcut_menu_info(menu_index) |
| 340 | + .icon_data_any_size(), |
| 341 | + 0); |
| 342 | + EXPECT_EQ(os_integration_state.shortcut_menus() |
| 343 | + .shortcut_menu_info(menu_index) |
| 344 | + .icon_data_maskable_size(), |
| 345 | + 0); |
| 346 | + EXPECT_EQ(os_integration_state.shortcut_menus() |
| 347 | + .shortcut_menu_info(menu_index) |
| 348 | + .icon_data_monochrome_size(), |
| 349 | + 0); |
| 350 | + } |
| 351 | + } else { |
| 352 | + ASSERT_FALSE(os_integration_state.has_shortcut_menus()); |
| 353 | + } |
| 354 | +} |
| 355 | + |
287 | 356 | INSTANTIATE_TEST_SUITE_P(
|
288 | 357 | All,
|
289 | 358 | ShortcutMenuHandlingSubManagerConfigureTest,
|
|
0 commit comments