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

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

Issue 2281743002: arc: Add support of default and OEM apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean Created 4 years, 3 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 AppListControllerDelegate* controller() { return controller_.get(); } 311 AppListControllerDelegate* controller() { return controller_.get(); }
312 312
313 Profile* profile() { return profile_.get(); } 313 Profile* profile() { return profile_.get(); }
314 314
315 ArcAppTest* arc_test() { return &arc_test_; } 315 ArcAppTest* arc_test() { return &arc_test_; }
316 316
317 const std::vector<arc::mojom::AppInfo>& fake_apps() const { 317 const std::vector<arc::mojom::AppInfo>& fake_apps() const {
318 return arc_test_.fake_apps(); 318 return arc_test_.fake_apps();
319 } 319 }
320 320
321 const std::vector<arc::mojom::AppInfo>& fake_default_apps() const {
322 return arc_test_.fake_default_apps();
323 }
324
321 const std::vector<arc::mojom::ArcPackageInfo>& fake_packages() const { 325 const std::vector<arc::mojom::ArcPackageInfo>& fake_packages() const {
322 return arc_test_.fake_packages(); 326 return arc_test_.fake_packages();
323 } 327 }
324 328
325 const std::vector<arc::mojom::ShortcutInfo>& fake_shortcuts() const { 329 const std::vector<arc::mojom::ShortcutInfo>& fake_shortcuts() const {
326 return arc_test_.fake_shortcuts(); 330 return arc_test_.fake_shortcuts();
327 } 331 }
328 332
329 arc::FakeAppInstance* app_instance() { 333 arc::FakeAppInstance* app_instance() {
330 return arc_test_.app_instance(); 334 return arc_test_.app_instance();
331 } 335 }
332 336
333 private: 337 private:
334 ArcAppTest arc_test_; 338 ArcAppTest arc_test_;
335 std::unique_ptr<app_list::AppListModel> model_; 339 std::unique_ptr<app_list::AppListModel> model_;
336 std::unique_ptr<test::TestAppListControllerDelegate> controller_; 340 std::unique_ptr<test::TestAppListControllerDelegate> controller_;
337 std::unique_ptr<ArcAppModelBuilder> builder_; 341 std::unique_ptr<ArcAppModelBuilder> builder_;
338 342
339 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderTest); 343 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderTest);
340 }; 344 };
341 345
346 class ArcDefaulAppTest : public ArcAppModelBuilderTest {
347 public:
348 ArcDefaulAppTest() {}
349 ~ArcDefaulAppTest() override {}
350
351
352 void SetUp() override {
353 ArcAppListPrefs::UseTestDefaultAppsDirectory();
354 ArcAppModelBuilderTest::SetUp();
355 }
356
357 private:
358 DISALLOW_COPY_AND_ASSIGN(ArcDefaulAppTest);
359 };
360
342 TEST_F(ArcAppModelBuilderTest, ArcPackagePref) { 361 TEST_F(ArcAppModelBuilderTest, ArcPackagePref) {
343 ValidateHavePackages(std::vector<arc::mojom::ArcPackageInfo>()); 362 ValidateHavePackages(std::vector<arc::mojom::ArcPackageInfo>());
344 app_instance()->SendRefreshPackageList(fake_packages()); 363 app_instance()->SendRefreshPackageList(fake_packages());
345 ValidateHavePackages(fake_packages()); 364 ValidateHavePackages(fake_packages());
346 365
347 arc::mojom::ArcPackageInfo package; 366 arc::mojom::ArcPackageInfo package;
348 package.package_name = kTestPackageName; 367 package.package_name = kTestPackageName;
349 package.package_version = 2; 368 package.package_version = 2;
350 package.last_backup_android_id = 2; 369 package.last_backup_android_id = 2;
351 package.last_backup_time = 2; 370 package.last_backup_time = 2;
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 EXPECT_EQ(now_time, app_info_before->last_launch_time); 979 EXPECT_EQ(now_time, app_info_before->last_launch_time);
961 980
962 app_instance()->SendPackageAppListRefreshed(apps[0].package_name, apps2); 981 app_instance()->SendPackageAppListRefreshed(apps[0].package_name, apps2);
963 ValidateHaveApps(apps2); 982 ValidateHaveApps(apps2);
964 983
965 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_after = 984 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_after =
966 prefs->GetApp(app_id); 985 prefs->GetApp(app_id);
967 ASSERT_TRUE(app_info_after); 986 ASSERT_TRUE(app_info_after);
968 EXPECT_EQ(now_time, app_info_after->last_launch_time); 987 EXPECT_EQ(now_time, app_info_after->last_launch_time);
969 } 988 }
989
990 TEST_F(ArcDefaulAppTest, DefaultApps) {
991 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
992 ASSERT_NE(nullptr, prefs);
993
994 ValidateHaveApps(fake_default_apps());
995
996 // Start normal apps. We should have apps from 2 subsets.
997 app_instance()->RefreshAppList();
998 app_instance()->SendRefreshAppList(fake_apps());
999
1000 std::vector<arc::mojom::AppInfo> all_apps = fake_default_apps();
1001 all_apps.insert(all_apps.end(), fake_apps().begin(), fake_apps().end());
1002 ValidateHaveApps(all_apps);
1003
1004 // However default apps are still not ready.
1005 for (const auto& default_app : fake_default_apps()) {
1006 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(
1007 ArcAppTest::GetAppId(default_app));
1008 ASSERT_TRUE(app_info);
1009 EXPECT_FALSE(app_info->ready);
1010 }
1011
1012 // Install default apps.
1013 for (const auto& default_app : fake_default_apps()) {
1014 std::vector<arc::mojom::AppInfo> package_apps;
1015 package_apps.push_back(default_app);
1016 app_instance()->SendPackageAppListRefreshed(default_app.package_name,
1017 package_apps);
1018 }
1019
1020 // And now default apps are ready.
1021 for (const auto& default_app : fake_default_apps()) {
1022 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(
1023 ArcAppTest::GetAppId(default_app));
1024 ASSERT_TRUE(app_info);
1025 EXPECT_TRUE(app_info->ready);
1026 }
1027
1028 // Uninstall first default package. Default app should go away.
1029 app_instance()->SendPackageUninstalled(all_apps[0].package_name);
1030 all_apps.erase(all_apps.begin());
1031 ValidateHaveApps(all_apps);
1032
1033 // OptOut and default apps should exist minus first.
1034 arc_test()->arc_auth_service()->DisableArc();
1035 all_apps = fake_default_apps();
1036 all_apps.erase(all_apps.begin());
1037 ValidateHaveApps(all_apps);
1038 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698