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

Unified Diff: chrome/browser/ui/app_list/arc/arc_app_unittest.cc

Issue 2858703002: arc: Support UNINSTALL_SHORTCUT (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/arc/arc_app_unittest.cc
diff --git a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
index 49be182c8ce180c9a5deb7ecc3a87480aa0045b3..4dea73c9122979d6c22bc18849c531419dfdddf0 100644
--- a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
+++ b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
@@ -580,11 +580,41 @@ TEST_P(ArcAppModelBuilderTest, RefreshAllFillsContent) {
ValidateHaveApps(fake_apps());
}
-TEST_P(ArcAppModelBuilderTest, InstallShortcut) {
+TEST_P(ArcAppModelBuilderTest, InstallUninstallShortcut) {
ValidateHaveApps(std::vector<arc::mojom::AppInfo>());
- app_instance()->SendInstallShortcuts(fake_shortcuts());
- ValidateHaveShortcuts(fake_shortcuts());
+ std::vector<arc::mojom::ShortcutInfo> shortcuts = fake_shortcuts();
+ ASSERT_GE(shortcuts.size(), 2U);
+
+ // Adding package is requred for safe call SendPackageUninstalled.
Luis Héctor Chávez 2017/05/02 19:48:16 nit: s/for safe call/to safely call/
khmel 2017/05/02 20:09:43 Done.
+ arc::mojom::ArcPackageInfo package;
+ package.package_name = shortcuts[1].package_name;
+ package.package_version = 1;
+ package.sync = true;
+ AddPackage(package);
+ app_instance()->SendPackageAdded(package);
+
+ app_instance()->SendInstallShortcuts(shortcuts);
+ ValidateHaveShortcuts(shortcuts);
+
+ // Uninstall first shortcut and validate it was removed.
+ const std::string package_name = shortcuts[0].package_name;
+ const std::string intent_uri = shortcuts[0].intent_uri;
+ shortcuts.erase(shortcuts.begin());
+ app_instance()->SendUninstallShortcut(package_name, intent_uri);
+ ValidateHaveShortcuts(shortcuts);
+
+ // Requests to uninstall non-existing shortcuts should be just ignored.
+ EXPECT_NE(package_name, shortcuts[0].package_name);
+ EXPECT_NE(intent_uri, shortcuts[0].intent_uri);
+ app_instance()->SendUninstallShortcut(package_name, shortcuts[0].intent_uri);
+ app_instance()->SendUninstallShortcut(shortcuts[0].package_name, intent_uri);
+ ValidateHaveShortcuts(shortcuts);
+
+ // Removing package should also remove associated shortcuts.
+ app_instance()->SendPackageUninstalled(shortcuts[0].package_name);
+ shortcuts.erase(shortcuts.begin());
+ ValidateHaveShortcuts(shortcuts);
}
TEST_P(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) {

Powered by Google App Engine
This is Rietveld 408576698