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

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

Issue 2228663003: arc: Add package app list updated event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
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 <string> 10 #include <string>
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 EXPECT_FALSE(launcher3.app_launched()); 904 EXPECT_FALSE(launcher3.app_launched());
905 EXPECT_FALSE(prefs->HasObserver(&launcher1)); 905 EXPECT_FALSE(prefs->HasObserver(&launcher1));
906 EXPECT_TRUE(prefs->HasObserver(&launcher3)); 906 EXPECT_TRUE(prefs->HasObserver(&launcher3));
907 907
908 ArcAppLauncher launcher2(profile(), id2, true); 908 ArcAppLauncher launcher2(profile(), id2, true);
909 EXPECT_TRUE(launcher2.app_launched()); 909 EXPECT_TRUE(launcher2.app_launched());
910 EXPECT_FALSE(prefs->HasObserver(&launcher2)); 910 EXPECT_FALSE(prefs->HasObserver(&launcher2));
911 ASSERT_EQ(2u, app_instance()->launch_requests().size()); 911 ASSERT_EQ(2u, app_instance()->launch_requests().size());
912 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); 912 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2));
913 } 913 }
914
915 TEST_F(ArcAppModelBuilderTest, ArcAppsOnPackageUpdated) {
916 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
917 ASSERT_NE(nullptr, prefs);
918
919 std::vector<arc::mojom::AppInfo> apps = fake_apps();
920 ASSERT_GE(3u, apps.size());
921 apps[0].package_name = apps[2].package_name;
922 apps[1].package_name = apps[2].package_name;
923 // Second app should be preserved after update.
924 std::vector<arc::mojom::AppInfo> apps1(apps.begin(), apps.begin() + 2);
925 std::vector<arc::mojom::AppInfo> apps2(apps.begin() + 1, apps.begin() + 3);
926
927 app_instance()->RefreshAppList();
928 app_instance()->SendRefreshAppList(apps1);
929 ValidateHaveApps(apps1);
930
931 const std::string app_id = ArcAppTest::GetAppId(apps[1]);
932 const base::Time now_time = base::Time::Now();
933 prefs->SetLastLaunchTime(app_id, now_time);
934 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_before =
935 prefs->GetApp(app_id);
936 ASSERT_TRUE(app_info_before);
937 EXPECT_EQ(now_time, app_info_before->last_launch_time);
938
939 app_instance()->SendPackageAppListRefreshed(apps[0].package_name, apps2);
940 ValidateHaveApps(apps2);
941
942 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_after =
943 prefs->GetApp(app_id);
944 ASSERT_TRUE(app_info_after);
945 EXPECT_EQ(now_time, app_info_after->last_launch_time);
946 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698