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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_unittest.cc

Issue 2896323004: Revert of arc: Invalide app icon on package update. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 // Validate loaded image. 1334 // Validate loaded image.
1335 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); 1335 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt());
1336 EXPECT_EQ(app_id, delegate.app_id()); 1336 EXPECT_EQ(app_id, delegate.app_id());
1337 ValidateIcon(delegate.image()); 1337 ValidateIcon(delegate.image());
1338 1338
1339 // No more updates are expected. 1339 // No more updates are expected.
1340 base::RunLoop().RunUntilIdle(); 1340 base::RunLoop().RunUntilIdle();
1341 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); 1341 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt());
1342 } 1342 }
1343 1343
1344 TEST_P(ArcAppModelBuilderTest, IconInvalidation) {
1345 std::vector<ui::ScaleFactor> supported_scale_factors;
1346 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P);
1347 supported_scale_factors.push_back(ui::SCALE_FACTOR_200P);
1348 ui::test::ScopedSetSupportedScaleFactors scoped_supported_scale_factors(
1349 supported_scale_factors);
1350
1351 ASSERT_FALSE(fake_apps().empty());
1352 std::vector<arc::mojom::AppInfo> apps = std::vector<arc::mojom::AppInfo>(
1353 fake_apps().begin(), fake_apps().begin() + 1);
1354
1355 const arc::mojom::AppInfo& app = apps[0];
1356 const std::string app_id = ArcAppTest::GetAppId(app);
1357
1358 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
1359 ASSERT_NE(nullptr, prefs);
1360
1361 app_instance()->RefreshAppList();
1362 app_instance()->SendRefreshAppList(apps);
1363
1364 prefs->MaybeRequestIcon(app_id, ui::SCALE_FACTOR_100P);
1365
1366 std::string png_data;
1367 EXPECT_TRUE(app_instance()->GenerateAndSendIcon(
1368 app, arc::mojom::ScaleFactor::SCALE_FACTOR_100P, &png_data));
1369 WaitForIconUpdates(profile_.get(), app_id, 1);
1370
1371 // Simulate ARC restart.
1372 arc_test()->TearDown();
1373 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting(
1374 profile_.get());
1375 arc_test()->SetUp(profile_.get());
1376 prefs = ArcAppListPrefs::Get(profile_.get());
1377 ASSERT_NE(nullptr, prefs);
1378 app_instance()->RefreshAppList();
1379 app_instance()->SendRefreshAppList(apps);
1380
1381 // No icon update requests on restart. Icons were not invalidated.
1382 EXPECT_TRUE(app_instance()->icon_requests().empty());
1383
1384 // Send new apps for the package. This should invalidate app icons.
1385 app_instance()->SendPackageAppListRefreshed(apps[0].package_name, apps);
1386 base::RunLoop().RunUntilIdle();
1387
1388 // Requests to reload icons are issued for all supported scales.
1389 const std::vector<std::unique_ptr<arc::FakeAppInstance::IconRequest>>&
1390 icon_requests = app_instance()->icon_requests();
1391 ASSERT_EQ(2U, icon_requests.size());
1392 EXPECT_TRUE(icon_requests[0]->IsForApp(app));
1393 EXPECT_EQ(icon_requests[0]->scale_factor(), ui::SCALE_FACTOR_100P);
1394 EXPECT_TRUE(icon_requests[1]->IsForApp(app));
1395 EXPECT_EQ(icon_requests[1]->scale_factor(), ui::SCALE_FACTOR_200P);
1396
1397 EXPECT_TRUE(app_instance()->GenerateAndSendIcon(
1398 app, arc::mojom::ScaleFactor::SCALE_FACTOR_100P, &png_data));
1399 EXPECT_TRUE(app_instance()->GenerateAndSendIcon(
1400 app, arc::mojom::ScaleFactor::SCALE_FACTOR_200P, &png_data));
1401 WaitForIconUpdates(profile_.get(), app_id, 2);
1402
1403 // Simulate ARC restart again.
1404 arc_test()->TearDown();
1405 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting(
1406 profile_.get());
1407 arc_test()->SetUp(profile_.get());
1408 prefs = ArcAppListPrefs::Get(profile_.get());
1409 ASSERT_NE(nullptr, prefs);
1410 app_instance()->RefreshAppList();
1411 app_instance()->SendRefreshAppList(apps);
1412
1413 // No new icon update requests on restart. Icons were invalidated and updated.
1414 EXPECT_TRUE(app_instance()->icon_requests().empty());
1415 }
1416
1417 TEST_P(ArcAppModelBuilderTest, AppLauncher) { 1344 TEST_P(ArcAppModelBuilderTest, AppLauncher) {
1418 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile()); 1345 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile());
1419 ASSERT_NE(nullptr, prefs); 1346 ASSERT_NE(nullptr, prefs);
1420 1347
1421 // App1 is called in deferred mode, after refreshing apps. 1348 // App1 is called in deferred mode, after refreshing apps.
1422 // App2 is never called since app is not avaialble. 1349 // App2 is never called since app is not avaialble.
1423 // App3 is never called immediately because app is available already. 1350 // App3 is never called immediately because app is available already.
1424 const arc::mojom::AppInfo& app1 = fake_apps()[0]; 1351 const arc::mojom::AppInfo& app1 = fake_apps()[0];
1425 const arc::mojom::AppInfo& app2 = fake_apps()[1]; 1352 const arc::mojom::AppInfo& app2 = fake_apps()[1];
1426 const arc::mojom::AppInfo& app3 = fake_apps()[2]; 1353 const arc::mojom::AppInfo& app3 = fake_apps()[2];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 // App should not appear now in the model but should be registered. 1406 // App should not appear now in the model but should be registered.
1480 EXPECT_FALSE(FindArcItem(app_id)); 1407 EXPECT_FALSE(FindArcItem(app_id));
1481 EXPECT_TRUE(prefs->IsRegistered(app_id)); 1408 EXPECT_TRUE(prefs->IsRegistered(app_id));
1482 } 1409 }
1483 1410
1484 TEST_P(ArcAppModelBuilderTest, ArcAppsAndShortcutsOnPackageChange) { 1411 TEST_P(ArcAppModelBuilderTest, ArcAppsAndShortcutsOnPackageChange) {
1485 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 1412 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
1486 ASSERT_NE(nullptr, prefs); 1413 ASSERT_NE(nullptr, prefs);
1487 1414
1488 std::vector<arc::mojom::AppInfo> apps = fake_apps(); 1415 std::vector<arc::mojom::AppInfo> apps = fake_apps();
1489 ASSERT_GE(apps.size(), 3U); 1416 ASSERT_GE(3u, apps.size());
1490 apps[0].package_name = apps[2].package_name; 1417 apps[0].package_name = apps[2].package_name;
1491 apps[1].package_name = apps[2].package_name; 1418 apps[1].package_name = apps[2].package_name;
1492 1419
1493 std::vector<arc::mojom::ShortcutInfo> shortcuts = fake_shortcuts(); 1420 std::vector<arc::mojom::ShortcutInfo> shortcuts = fake_shortcuts();
1494 for (auto& shortcut : shortcuts) 1421 for (auto& shortcut : shortcuts)
1495 shortcut.package_name = apps[0].package_name; 1422 shortcut.package_name = apps[0].package_name;
1496 1423
1497 // Second app should be preserved after update. 1424 // Second app should be preserved after update.
1498 std::vector<arc::mojom::AppInfo> apps1(apps.begin(), apps.begin() + 2); 1425 std::vector<arc::mojom::AppInfo> apps1(apps.begin(), apps.begin() + 2);
1499 std::vector<arc::mojom::AppInfo> apps2(apps.begin() + 1, apps.begin() + 3); 1426 std::vector<arc::mojom::AppInfo> apps2(apps.begin() + 1, apps.begin() + 3);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 ::testing::ValuesIn(kUnmanagedArcStates)); 1665 ::testing::ValuesIn(kUnmanagedArcStates));
1739 INSTANTIATE_TEST_CASE_P(, 1666 INSTANTIATE_TEST_CASE_P(,
1740 ArcDefaulAppForManagedUserTest, 1667 ArcDefaulAppForManagedUserTest,
1741 ::testing::ValuesIn(kManagedArcStates)); 1668 ::testing::ValuesIn(kManagedArcStates));
1742 INSTANTIATE_TEST_CASE_P(, 1669 INSTANTIATE_TEST_CASE_P(,
1743 ArcPlayStoreAppTest, 1670 ArcPlayStoreAppTest,
1744 ::testing::ValuesIn(kUnmanagedArcStates)); 1671 ::testing::ValuesIn(kUnmanagedArcStates));
1745 INSTANTIATE_TEST_CASE_P(, 1672 INSTANTIATE_TEST_CASE_P(,
1746 ArcAppModelBuilderRecreate, 1673 ArcAppModelBuilderRecreate,
1747 ::testing::ValuesIn(kUnmanagedArcStates)); 1674 ::testing::ValuesIn(kUnmanagedArcStates));
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698