| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/common/shelf/shelf_delegate.h" | 5 #include "ash/common/shelf/shelf_delegate.h" |
| 6 #include "ash/common/wm_shell.h" | 6 #include "ash/common/wm_shell.h" |
| 7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 void SendPackageUpdated(const std::string& package_name, bool multi_app) { | 221 void SendPackageUpdated(const std::string& package_name, bool multi_app) { |
| 222 app_host()->OnPackageAppListRefreshed( | 222 app_host()->OnPackageAppListRefreshed( |
| 223 package_name, GetTestAppsList(package_name, multi_app)); | 223 package_name, GetTestAppsList(package_name, multi_app)); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void SendPackageRemoved(const std::string& package_name) { | 226 void SendPackageRemoved(const std::string& package_name) { |
| 227 app_host()->OnPackageRemoved(package_name); | 227 app_host()->OnPackageRemoved(package_name); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void SendInstallationStarted() { | 230 void SendInstallationStarted(const std::string& package_name) { |
| 231 app_host()->OnInstallationStarted(); | 231 app_host()->OnInstallationStarted(package_name); |
| 232 base::RunLoop().RunUntilIdle(); | 232 base::RunLoop().RunUntilIdle(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void SendInstallationFinished() { | 235 void SendInstallationFinished(const std::string& package_name, bool success) { |
| 236 app_host()->OnInstallationFinished(); | 236 arc::mojom::InstallationResult result; |
| 237 result.package_name = package_name; |
| 238 result.success = success; |
| 239 app_host()->OnInstallationFinished( |
| 240 arc::mojom::InstallationResultPtr(result.Clone())); |
| 237 base::RunLoop().RunUntilIdle(); | 241 base::RunLoop().RunUntilIdle(); |
| 238 } | 242 } |
| 239 | 243 |
| 240 void StartInstance() { | 244 void StartInstance() { |
| 241 if (arc_session_manager()->profile() != profile()) | 245 if (arc_session_manager()->profile() != profile()) |
| 242 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); | 246 arc_session_manager()->OnPrimaryUserProfilePrepared(profile()); |
| 243 app_instance_observer()->OnInstanceReady(); | 247 app_instance_observer()->OnInstanceReady(); |
| 244 } | 248 } |
| 245 | 249 |
| 246 void StopInstance() { | 250 void StopInstance() { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 414 |
| 411 // This test validates that app list is shown on new package and not shown | 415 // This test validates that app list is shown on new package and not shown |
| 412 // on package update. | 416 // on package update. |
| 413 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, AppListShown) { | 417 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, AppListShown) { |
| 414 StartInstance(); | 418 StartInstance(); |
| 415 AppListService* app_list_service = AppListService::Get(); | 419 AppListService* app_list_service = AppListService::Get(); |
| 416 ASSERT_TRUE(app_list_service); | 420 ASSERT_TRUE(app_list_service); |
| 417 | 421 |
| 418 EXPECT_FALSE(app_list_service->IsAppListVisible()); | 422 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 419 | 423 |
| 420 SendInstallationStarted(); | 424 SendInstallationStarted(kTestAppPackage); |
| 421 SendInstallationStarted(); | 425 SendInstallationStarted(kTestAppPackage2); |
| 422 | 426 |
| 423 // New package is available. Show app list. | 427 // New package is available. Show app list. |
| 424 SendInstallationFinished(); | 428 SendInstallationFinished(kTestAppPackage, true); |
| 425 InstallTestApps(kTestAppPackage, false); | 429 InstallTestApps(kTestAppPackage, false); |
| 426 SendPackageAdded(kTestAppPackage, true); | 430 SendPackageAdded(kTestAppPackage, true); |
| 427 EXPECT_TRUE(app_list_service->IsAppListVisible()); | 431 EXPECT_TRUE(app_list_service->IsAppListVisible()); |
| 428 | 432 |
| 429 app_list_service->DismissAppList(); | 433 app_list_service->DismissAppList(); |
| 430 EXPECT_FALSE(app_list_service->IsAppListVisible()); | 434 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 431 | 435 |
| 432 // Send package update event. App list is not shown. | 436 // Send package update event. App list is not shown. |
| 433 SendPackageAdded(kTestAppPackage, true); | 437 SendPackageAdded(kTestAppPackage, true); |
| 434 EXPECT_FALSE(app_list_service->IsAppListVisible()); | 438 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 435 | 439 |
| 436 // Install next package from batch. Next new package is available. | 440 // Install next package from batch. Next new package is available. |
| 437 // Don't show app list. | 441 // Don't show app list. |
| 438 SendInstallationFinished(); | 442 SendInstallationFinished(kTestAppPackage2, true); |
| 439 InstallTestApps(kTestAppPackage2, false); | 443 InstallTestApps(kTestAppPackage2, false); |
| 440 SendPackageAdded(kTestAppPackage2, true); | 444 SendPackageAdded(kTestAppPackage2, true); |
| 441 EXPECT_FALSE(app_list_service->IsAppListVisible()); | 445 EXPECT_FALSE(app_list_service->IsAppListVisible()); |
| 442 | 446 |
| 443 // Run next installation batch. App list should be shown again. | 447 // Run next installation batch. App list should be shown again. |
| 444 SendInstallationStarted(); | 448 SendInstallationStarted(kTestAppPackage3); |
| 445 SendInstallationFinished(); | 449 SendInstallationFinished(kTestAppPackage3, true); |
| 446 InstallTestApps(kTestAppPackage3, false); | 450 InstallTestApps(kTestAppPackage3, false); |
| 447 SendPackageAdded(kTestAppPackage3, true); | 451 SendPackageAdded(kTestAppPackage3, true); |
| 448 EXPECT_TRUE(app_list_service->IsAppListVisible()); | 452 EXPECT_TRUE(app_list_service->IsAppListVisible()); |
| 449 app_list_service->DismissAppList(); | 453 app_list_service->DismissAppList(); |
| 450 } | 454 } |
| 451 | 455 |
| 452 // Test AppListControllerDelegate::IsAppOpen for Arc apps. | 456 // Test AppListControllerDelegate::IsAppOpen for Arc apps. |
| 453 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, IsAppOpen) { | 457 IN_PROC_BROWSER_TEST_F(ArcAppLauncherBrowserTest, IsAppOpen) { |
| 454 StartInstance(); | 458 StartInstance(); |
| 455 InstallTestApps(kTestAppPackage, false); | 459 InstallTestApps(kTestAppPackage, false); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 app_host()->OnTaskDestroyed(2); | 535 app_host()->OnTaskDestroyed(2); |
| 532 EXPECT_EQ(controller2, GetAppItemController(shelf_id2)); | 536 EXPECT_EQ(controller2, GetAppItemController(shelf_id2)); |
| 533 // Destroy task #2, this kills shelf group 2 | 537 // Destroy task #2, this kills shelf group 2 |
| 534 app_host()->OnTaskDestroyed(3); | 538 app_host()->OnTaskDestroyed(3); |
| 535 EXPECT_FALSE(GetAppItemController(shelf_id2)); | 539 EXPECT_FALSE(GetAppItemController(shelf_id2)); |
| 536 | 540 |
| 537 // Disable Arc, this removes app and as result kills shelf group 3. | 541 // Disable Arc, this removes app and as result kills shelf group 3. |
| 538 arc::ArcSessionManager::Get()->DisableArc(); | 542 arc::ArcSessionManager::Get()->DisableArc(); |
| 539 EXPECT_FALSE(GetAppItemController(shelf_id3)); | 543 EXPECT_FALSE(GetAppItemController(shelf_id3)); |
| 540 } | 544 } |
| OLD | NEW |