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

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

Issue 2601323002: arc: Handle default app not availble case. (Closed)
Patch Set: rebase Created 3 years, 11 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 <memory> 10 #include <memory>
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 fake_default_apps()[0].package_name, package_apps); 1281 fake_default_apps()[0].package_name, package_apps);
1282 ValidateHaveApps(fake_default_apps()); 1282 ValidateHaveApps(fake_default_apps());
1283 1283
1284 // Validate that OEM state is preserved. 1284 // Validate that OEM state is preserved.
1285 for (const auto& default_app : fake_default_apps()) { 1285 for (const auto& default_app : fake_default_apps()) {
1286 const std::string app_id = ArcAppTest::GetAppId(default_app); 1286 const std::string app_id = ArcAppTest::GetAppId(default_app);
1287 EXPECT_EQ(oem_states[app_id], prefs->IsOem(app_id)); 1287 EXPECT_EQ(oem_states[app_id], prefs->IsOem(app_id));
1288 } 1288 }
1289 } 1289 }
1290 1290
1291 TEST_F(ArcDefaulAppTest, DefaultAppsNotAvailable) {
1292 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
1293 ASSERT_NE(nullptr, prefs);
1294
1295 ValidateHaveApps(fake_default_apps());
1296
1297 const std::vector<arc::mojom::AppInfo> empty_app_list;
1298
1299 app_instance()->RefreshAppList();
1300 app_instance()->SendRefreshAppList(empty_app_list);
1301
1302 ValidateHaveApps(fake_default_apps());
1303
1304 prefs->SimulateDefaultAppAvailabilityTimeoutForTesting();
1305
1306 // No default app installation and already installed packages.
1307 ValidateHaveApps(empty_app_list);
1308 }
1309
1310 TEST_F(ArcDefaulAppTest, DefaultAppsInstallation) {
1311 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
1312 ASSERT_NE(nullptr, prefs);
1313
1314 const std::vector<arc::mojom::AppInfo> empty_app_list;
1315
1316 ValidateHaveApps(fake_default_apps());
1317
1318 app_instance()->RefreshAppList();
1319 app_instance()->SendRefreshAppList(empty_app_list);
1320
1321 ValidateHaveApps(fake_default_apps());
1322
1323 // Notify that default installations have been started.
1324 for (const auto& fake_app : fake_default_apps())
1325 app_instance()->SendInstallationStarted(fake_app.package_name);
1326
1327 // Timeout does not affect default app availability because all installations
1328 // for default apps have been started.
1329 prefs->SimulateDefaultAppAvailabilityTimeoutForTesting();
1330 ValidateHaveApps(fake_default_apps());
1331
1332 const arc::mojom::AppInfo& app_last = fake_default_apps().back();
1333 std::vector<arc::mojom::AppInfo> available_apps = fake_default_apps();
1334 available_apps.pop_back();
1335
1336 for (const auto& fake_app : available_apps)
1337 app_instance()->SendInstallationFinished(fake_app.package_name, true);
1338
1339 // So far we have all default apps available because not all installations
1340 // completed.
1341 ValidateHaveApps(fake_default_apps());
1342
1343 // Last default app installation failed.
1344 app_instance()->SendInstallationFinished(app_last.package_name, false);
1345
1346 // We should have all default apps except last.
1347 ValidateHaveApps(available_apps);
1348 }
1349
1291 TEST_F(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) { 1350 TEST_F(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) {
1292 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get()); 1351 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get());
1293 ASSERT_TRUE(prefs); 1352 ASSERT_TRUE(prefs);
1294 1353
1295 // There is no default app for managed users except Play Store 1354 // There is no default app for managed users except Play Store
1296 for (const auto& app : fake_default_apps()) { 1355 for (const auto& app : fake_default_apps()) {
1297 const std::string app_id = ArcAppTest::GetAppId(app); 1356 const std::string app_id = ArcAppTest::GetAppId(app);
1298 EXPECT_FALSE(prefs->IsRegistered(app_id)); 1357 EXPECT_FALSE(prefs->IsRegistered(app_id));
1299 EXPECT_FALSE(prefs->GetApp(app_id)); 1358 EXPECT_FALSE(prefs->GetApp(app_id));
1300 } 1359 }
1301 } 1360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698