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

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

Issue 2549583003: arc: Fix error when uninstalled default app appears in next session. (Closed)
Patch Set: comment fixed Created 4 years 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 365
366 class ArcDefaulAppTest : public ArcAppModelBuilderTest { 366 class ArcDefaulAppTest : public ArcAppModelBuilderTest {
367 public: 367 public:
368 ArcDefaulAppTest() = default; 368 ArcDefaulAppTest() = default;
369 ~ArcDefaulAppTest() override = default; 369 ~ArcDefaulAppTest() override = default;
370 370
371 protected: 371 protected:
372 // ArcAppModelBuilderTest: 372 // ArcAppModelBuilderTest:
373 void OnBeforeArcTestSetup() override { 373 void OnBeforeArcTestSetup() override {
374 ArcDefaultAppList::UseTestAppsDirectory(); 374 ArcDefaultAppList::UseTestAppsDirectory();
375 arc::ArcPackageSyncableServiceFactory::GetInstance()->SetTestingFactory(
376 profile_.get(), nullptr);
375 } 377 }
376 378
377 private: 379 private:
378 DISALLOW_COPY_AND_ASSIGN(ArcDefaulAppTest); 380 DISALLOW_COPY_AND_ASSIGN(ArcDefaulAppTest);
379 }; 381 };
380 382
381 class ArcDefaulAppForManagedUserTest : public ArcDefaulAppTest { 383 class ArcDefaulAppForManagedUserTest : public ArcDefaulAppTest {
382 public: 384 public:
383 ArcDefaulAppForManagedUserTest() = default; 385 ArcDefaulAppForManagedUserTest() = default;
384 ~ArcDefaulAppForManagedUserTest() override = default; 386 ~ArcDefaulAppForManagedUserTest() override = default;
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 1176
1175 // Install default apps. 1177 // Install default apps.
1176 for (const auto& default_app : fake_default_apps()) { 1178 for (const auto& default_app : fake_default_apps()) {
1177 std::vector<arc::mojom::AppInfo> package_apps; 1179 std::vector<arc::mojom::AppInfo> package_apps;
1178 package_apps.push_back(default_app); 1180 package_apps.push_back(default_app);
1179 app_instance()->SendPackageAppListRefreshed(default_app.package_name, 1181 app_instance()->SendPackageAppListRefreshed(default_app.package_name,
1180 package_apps); 1182 package_apps);
1181 } 1183 }
1182 1184
1183 // And now default apps are ready. 1185 // And now default apps are ready.
1186 std::map<std::string, bool> oem_states;
1184 for (const auto& default_app : fake_default_apps()) { 1187 for (const auto& default_app : fake_default_apps()) {
1185 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp( 1188 const std::string app_id = ArcAppTest::GetAppId(default_app);
1186 ArcAppTest::GetAppId(default_app)); 1189 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
1187 ASSERT_TRUE(app_info); 1190 ASSERT_TRUE(app_info);
1188 EXPECT_TRUE(app_info->ready); 1191 EXPECT_TRUE(app_info->ready);
1192 oem_states[app_id] = prefs->IsOem(app_id);
1189 } 1193 }
1190 1194
1191 // Uninstall first default package. Default app should go away. 1195 // Uninstall first default package. Default app should go away.
1192 app_instance()->SendPackageUninstalled(all_apps[0].package_name); 1196 app_instance()->SendPackageUninstalled(all_apps[0].package_name);
1193 all_apps.erase(all_apps.begin()); 1197 all_apps.erase(all_apps.begin());
1194 ValidateHaveApps(all_apps); 1198 ValidateHaveApps(all_apps);
1195 1199
1196 // OptOut and default apps should exist minus first. 1200 // OptOut and default apps should exist minus first.
1197 arc_test()->arc_session_manager()->DisableArc(); 1201 arc_test()->arc_session_manager()->DisableArc();
1198 all_apps = fake_default_apps(); 1202 all_apps = fake_default_apps();
1199 all_apps.erase(all_apps.begin()); 1203 all_apps.erase(all_apps.begin());
1200 ValidateHaveApps(all_apps); 1204 ValidateHaveApps(all_apps);
1205
1206 // Sign-out and sign-in again. Removed default app should not appear.
1207 arc_test()->TearDown();
1208 ResetBuilder();
1209 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting(
1210 profile_.get());
1211 arc_test()->SetUp(profile_.get());
1212 CreateBuilder();
1213
1214 // Prefs are changed.
1215 prefs = ArcAppListPrefs::Get(profile_.get());
1216 ASSERT_NE(nullptr, prefs);
1217
1218 ValidateHaveApps(all_apps);
1219
1220 // Install deleted default app again.
1221 std::vector<arc::mojom::AppInfo> package_apps;
1222 package_apps.push_back(fake_default_apps()[0]);
1223 app_instance()->SendPackageAppListRefreshed(
1224 fake_default_apps()[0].package_name, package_apps);
1225 ValidateHaveApps(fake_default_apps());
1226
1227 // Validate that OEM state is preserved.
1228 for (const auto& default_app : fake_default_apps()) {
1229 const std::string app_id = ArcAppTest::GetAppId(default_app);
1230 EXPECT_EQ(oem_states[app_id], prefs->IsOem(app_id));
1231 }
1201 } 1232 }
1202 1233
1203 TEST_F(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) { 1234 TEST_F(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) {
1204 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get()); 1235 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get());
1205 ASSERT_TRUE(prefs); 1236 ASSERT_TRUE(prefs);
1206 1237
1207 // There is no default app for managed users except Play Store 1238 // There is no default app for managed users except Play Store
1208 for (const auto& app : fake_default_apps()) { 1239 for (const auto& app : fake_default_apps()) {
1209 const std::string app_id = ArcAppTest::GetAppId(app); 1240 const std::string app_id = ArcAppTest::GetAppId(app);
1210 EXPECT_FALSE(prefs->IsRegistered(app_id)); 1241 EXPECT_FALSE(prefs->IsRegistered(app_id));
1211 EXPECT_FALSE(prefs->GetApp(app_id)); 1242 EXPECT_FALSE(prefs->GetApp(app_id));
1212 } 1243 }
1213 } 1244 }
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