| OLD | NEW |
| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 290 } |
| 291 | 291 |
| 292 void RemovePackage(const arc::mojom::ArcPackageInfo& package) { | 292 void RemovePackage(const arc::mojom::ArcPackageInfo& package) { |
| 293 arc_test_.RemovePackage(package); | 293 arc_test_.RemovePackage(package); |
| 294 } | 294 } |
| 295 | 295 |
| 296 AppListControllerDelegate* controller() { return controller_.get(); } | 296 AppListControllerDelegate* controller() { return controller_.get(); } |
| 297 | 297 |
| 298 Profile* profile() { return profile_.get(); } | 298 Profile* profile() { return profile_.get(); } |
| 299 | 299 |
| 300 ArcAppTest* arc_test() { return &arc_test_; } |
| 301 |
| 300 const std::vector<arc::mojom::AppInfo>& fake_apps() const { | 302 const std::vector<arc::mojom::AppInfo>& fake_apps() const { |
| 301 return arc_test_.fake_apps(); | 303 return arc_test_.fake_apps(); |
| 302 } | 304 } |
| 303 | 305 |
| 304 const std::vector<arc::mojom::ArcPackageInfo>& fake_packages() const { | 306 const std::vector<arc::mojom::ArcPackageInfo>& fake_packages() const { |
| 305 return arc_test_.fake_packages(); | 307 return arc_test_.fake_packages(); |
| 306 } | 308 } |
| 307 | 309 |
| 308 const std::vector<arc::mojom::ShortcutInfo>& fake_shortcuts() const { | 310 const std::vector<arc::mojom::ShortcutInfo>& fake_shortcuts() const { |
| 309 return arc_test_.fake_shortcuts(); | 311 return arc_test_.fake_shortcuts(); |
| 310 } | 312 } |
| 311 | 313 |
| 312 arc::FakeArcBridgeService* bridge_service() { | |
| 313 return arc_test_.bridge_service(); | |
| 314 } | |
| 315 | |
| 316 arc::FakeAppInstance* app_instance() { | 314 arc::FakeAppInstance* app_instance() { |
| 317 return arc_test_.app_instance(); | 315 return arc_test_.app_instance(); |
| 318 } | 316 } |
| 319 | 317 |
| 320 private: | 318 private: |
| 321 ArcAppTest arc_test_; | 319 ArcAppTest arc_test_; |
| 322 std::unique_ptr<app_list::AppListModel> model_; | 320 std::unique_ptr<app_list::AppListModel> model_; |
| 323 std::unique_ptr<test::TestAppListControllerDelegate> controller_; | 321 std::unique_ptr<test::TestAppListControllerDelegate> controller_; |
| 324 std::unique_ptr<ArcAppModelBuilder> builder_; | 322 std::unique_ptr<ArcAppModelBuilder> builder_; |
| 325 | 323 |
| 326 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderTest); | 324 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderTest); |
| 327 }; | 325 }; |
| 328 | 326 |
| 329 TEST_F(ArcAppModelBuilderTest, ArcPackagePref) { | 327 TEST_F(ArcAppModelBuilderTest, ArcPackagePref) { |
| 330 ValidateHavePackages(std::vector<arc::mojom::ArcPackageInfo>()); | 328 ValidateHavePackages(std::vector<arc::mojom::ArcPackageInfo>()); |
| 331 bridge_service()->SetReady(); | |
| 332 app_instance()->SendRefreshPackageList(fake_packages()); | 329 app_instance()->SendRefreshPackageList(fake_packages()); |
| 333 ValidateHavePackages(fake_packages()); | 330 ValidateHavePackages(fake_packages()); |
| 334 | 331 |
| 335 arc::mojom::ArcPackageInfo package; | 332 arc::mojom::ArcPackageInfo package; |
| 336 package.package_name = kTestPackageName; | 333 package.package_name = kTestPackageName; |
| 337 package.package_version = 2; | 334 package.package_version = 2; |
| 338 package.last_backup_android_id = 2; | 335 package.last_backup_android_id = 2; |
| 339 package.last_backup_time = 2; | 336 package.last_backup_time = 2; |
| 340 package.sync = true; | 337 package.sync = true; |
| 341 | 338 |
| 342 RemovePackage(package); | 339 RemovePackage(package); |
| 343 app_instance()->SendPackageUninstalled(package.package_name); | 340 app_instance()->SendPackageUninstalled(package.package_name); |
| 344 ValidateHavePackages(fake_packages()); | 341 ValidateHavePackages(fake_packages()); |
| 345 | 342 |
| 346 AddPackage(package); | 343 AddPackage(package); |
| 347 app_instance()->SendPackageAdded(package); | 344 app_instance()->SendPackageAdded(package); |
| 348 ValidateHavePackages(fake_packages()); | 345 ValidateHavePackages(fake_packages()); |
| 349 } | 346 } |
| 350 | 347 |
| 351 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) { | 348 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) { |
| 352 // There should already have been one call, when the interface was | 349 // There should already have been one call, when the interface was |
| 353 // registered. | 350 // registered. |
| 354 EXPECT_EQ(1, app_instance()->refresh_app_list_count()); | 351 EXPECT_EQ(1, app_instance()->refresh_app_list_count()); |
| 355 bridge_service()->SetReady(); | |
| 356 app_instance()->RefreshAppList(); | 352 app_instance()->RefreshAppList(); |
| 357 EXPECT_EQ(2, app_instance()->refresh_app_list_count()); | 353 EXPECT_EQ(2, app_instance()->refresh_app_list_count()); |
| 358 } | 354 } |
| 359 | 355 |
| 360 TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) { | 356 TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) { |
| 361 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 357 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
| 362 bridge_service()->SetReady(); | |
| 363 app_instance()->RefreshAppList(); | 358 app_instance()->RefreshAppList(); |
| 364 app_instance()->SendRefreshAppList(fake_apps()); | 359 app_instance()->SendRefreshAppList(fake_apps()); |
| 365 ValidateHaveApps(fake_apps()); | 360 ValidateHaveApps(fake_apps()); |
| 366 } | 361 } |
| 367 | 362 |
| 368 TEST_F(ArcAppModelBuilderTest, InstallShortcut) { | 363 TEST_F(ArcAppModelBuilderTest, InstallShortcut) { |
| 369 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 364 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
| 370 bridge_service()->SetReady(); | |
| 371 | 365 |
| 372 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 366 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
| 373 ValidateHaveShortcuts(fake_shortcuts()); | 367 ValidateHaveShortcuts(fake_shortcuts()); |
| 374 } | 368 } |
| 375 | 369 |
| 376 TEST_F(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) { | 370 TEST_F(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) { |
| 377 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 371 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
| 378 bridge_service()->SetReady(); | |
| 379 app_instance()->RefreshAppList(); | 372 app_instance()->RefreshAppList(); |
| 380 app_instance()->SendRefreshAppList(fake_apps()); | 373 app_instance()->SendRefreshAppList(fake_apps()); |
| 381 ValidateHaveApps(fake_apps()); | 374 ValidateHaveApps(fake_apps()); |
| 382 | 375 |
| 383 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 376 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
| 384 ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); | 377 ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); |
| 385 | 378 |
| 386 app_instance()->RefreshAppList(); | 379 app_instance()->RefreshAppList(); |
| 387 app_instance()->SendRefreshAppList(fake_apps()); | 380 app_instance()->SendRefreshAppList(fake_apps()); |
| 388 ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); | 381 ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); |
| 389 } | 382 } |
| 390 | 383 |
| 391 TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) { | 384 TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) { |
| 392 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 385 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
| 393 bridge_service()->SetReady(); | |
| 394 app_instance()->RefreshAppList(); | 386 app_instance()->RefreshAppList(); |
| 395 // Send info about all fake apps except last. | 387 // Send info about all fake apps except last. |
| 396 std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(), | 388 std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(), |
| 397 fake_apps().end() - 1); | 389 fake_apps().end() - 1); |
| 398 app_instance()->SendRefreshAppList(apps1); | 390 app_instance()->SendRefreshAppList(apps1); |
| 399 // At this point all apps (except last) should exist and be ready. | 391 // At this point all apps (except last) should exist and be ready. |
| 400 ValidateHaveApps(apps1); | 392 ValidateHaveApps(apps1); |
| 401 ValidateAppReadyState(apps1, true); | 393 ValidateAppReadyState(apps1, true); |
| 402 | 394 |
| 403 // Send info about all fake apps except first. | 395 // Send info about all fake apps except first. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 418 std::vector<arc::mojom::AppInfo> no_apps; | 410 std::vector<arc::mojom::AppInfo> no_apps; |
| 419 app_instance()->SendRefreshAppList(no_apps); | 411 app_instance()->SendRefreshAppList(no_apps); |
| 420 // At this point no app should exist. | 412 // At this point no app should exist. |
| 421 ValidateHaveApps(no_apps); | 413 ValidateHaveApps(no_apps); |
| 422 } | 414 } |
| 423 | 415 |
| 424 TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveApps) { | 416 TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveApps) { |
| 425 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 417 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 426 ASSERT_NE(nullptr, prefs); | 418 ASSERT_NE(nullptr, prefs); |
| 427 | 419 |
| 428 bridge_service()->SetReady(); | |
| 429 app_instance()->RefreshAppList(); | 420 app_instance()->RefreshAppList(); |
| 430 EXPECT_EQ(0u, GetArcItemCount()); | 421 EXPECT_EQ(0u, GetArcItemCount()); |
| 431 EXPECT_EQ(0u, prefs->GetAppIds().size()); | 422 EXPECT_EQ(0u, prefs->GetAppIds().size()); |
| 432 | 423 |
| 433 app_instance()->SendRefreshAppList(fake_apps()); | 424 app_instance()->SendRefreshAppList(fake_apps()); |
| 434 std::vector<std::string> ids = prefs->GetAppIds(); | 425 std::vector<std::string> ids = prefs->GetAppIds(); |
| 435 EXPECT_EQ(fake_apps().size(), ids.size()); | 426 EXPECT_EQ(fake_apps().size(), ids.size()); |
| 436 ValidateAppReadyState(fake_apps(), true); | 427 ValidateAppReadyState(fake_apps(), true); |
| 437 | 428 |
| 438 // Stopping service does not delete items. It makes them non-ready. | 429 // Stopping service does not delete items. It makes them non-ready. |
| 439 bridge_service()->SetStopped(); | 430 arc_test()->StopArcInstance(); |
| 440 // Ids should be the same. | 431 // Ids should be the same. |
| 441 EXPECT_EQ(ids, prefs->GetAppIds()); | 432 EXPECT_EQ(ids, prefs->GetAppIds()); |
| 442 ValidateAppReadyState(fake_apps(), false); | 433 ValidateAppReadyState(fake_apps(), false); |
| 443 | 434 |
| 444 // Setting service ready does not change anything because RefreshAppList is | |
| 445 // not called. | |
| 446 bridge_service()->SetReady(); | |
| 447 // Ids should be the same. | 435 // Ids should be the same. |
| 448 EXPECT_EQ(ids, prefs->GetAppIds()); | 436 EXPECT_EQ(ids, prefs->GetAppIds()); |
| 449 ValidateAppReadyState(fake_apps(), false); | 437 ValidateAppReadyState(fake_apps(), false); |
| 450 | 438 |
| 451 // Refreshing app list makes apps available. | 439 // Refreshing app list makes apps available. |
| 452 app_instance()->SendRefreshAppList(fake_apps()); | 440 app_instance()->SendRefreshAppList(fake_apps()); |
| 453 EXPECT_EQ(ids, prefs->GetAppIds()); | 441 EXPECT_EQ(ids, prefs->GetAppIds()); |
| 454 ValidateAppReadyState(fake_apps(), true); | 442 ValidateAppReadyState(fake_apps(), true); |
| 455 } | 443 } |
| 456 | 444 |
| 457 TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveShortcuts) { | 445 TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveShortcuts) { |
| 458 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 446 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 459 ASSERT_NE(nullptr, prefs); | 447 ASSERT_NE(nullptr, prefs); |
| 460 | 448 |
| 461 bridge_service()->SetReady(); | |
| 462 app_instance()->RefreshAppList(); | 449 app_instance()->RefreshAppList(); |
| 463 EXPECT_EQ(0u, GetArcItemCount()); | 450 EXPECT_EQ(0u, GetArcItemCount()); |
| 464 EXPECT_EQ(0u, prefs->GetAppIds().size()); | 451 EXPECT_EQ(0u, prefs->GetAppIds().size()); |
| 465 | 452 |
| 466 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 453 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
| 467 std::vector<std::string> ids = prefs->GetAppIds(); | 454 std::vector<std::string> ids = prefs->GetAppIds(); |
| 468 EXPECT_EQ(fake_shortcuts().size(), ids.size()); | 455 EXPECT_EQ(fake_shortcuts().size(), ids.size()); |
| 469 ValidateShortcutReadyState(fake_shortcuts(), true); | 456 ValidateShortcutReadyState(fake_shortcuts(), true); |
| 470 | 457 |
| 471 // Stopping service does not delete items. It makes them non-ready. | 458 // Stopping service does not delete items. It makes them non-ready. |
| 472 bridge_service()->SetStopped(); | 459 arc_test()->StopArcInstance(); |
| 473 // Ids should be the same. | 460 // Ids should be the same. |
| 474 EXPECT_EQ(ids, prefs->GetAppIds()); | 461 EXPECT_EQ(ids, prefs->GetAppIds()); |
| 475 ValidateShortcutReadyState(fake_shortcuts(), false); | 462 ValidateShortcutReadyState(fake_shortcuts(), false); |
| 476 | 463 |
| 477 // Setting service ready does not change anything because RefreshAppList is | |
| 478 // not called. | |
| 479 bridge_service()->SetReady(); | |
| 480 // Ids should be the same. | 464 // Ids should be the same. |
| 481 EXPECT_EQ(ids, prefs->GetAppIds()); | 465 EXPECT_EQ(ids, prefs->GetAppIds()); |
| 482 ValidateShortcutReadyState(fake_shortcuts(), false); | 466 ValidateShortcutReadyState(fake_shortcuts(), false); |
| 483 | 467 |
| 484 // Refreshing app list makes apps available. | 468 // Refreshing app list makes apps available. |
| 485 app_instance()->RefreshAppList(); | 469 app_instance()->RefreshAppList(); |
| 486 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); | 470 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); |
| 487 EXPECT_EQ(ids, prefs->GetAppIds()); | 471 EXPECT_EQ(ids, prefs->GetAppIds()); |
| 488 ValidateShortcutReadyState(fake_shortcuts(), true); | 472 ValidateShortcutReadyState(fake_shortcuts(), true); |
| 489 } | 473 } |
| 490 | 474 |
| 491 TEST_F(ArcAppModelBuilderTest, RestartPreserveApps) { | 475 TEST_F(ArcAppModelBuilderTest, RestartPreserveApps) { |
| 492 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 476 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 493 ASSERT_NE(nullptr, prefs); | 477 ASSERT_NE(nullptr, prefs); |
| 494 | 478 |
| 495 // Start from scratch and fill with apps. | 479 // Start from scratch and fill with apps. |
| 496 bridge_service()->SetReady(); | |
| 497 app_instance()->SendRefreshAppList(fake_apps()); | 480 app_instance()->SendRefreshAppList(fake_apps()); |
| 498 std::vector<std::string> ids = prefs->GetAppIds(); | 481 std::vector<std::string> ids = prefs->GetAppIds(); |
| 499 EXPECT_EQ(fake_apps().size(), ids.size()); | 482 EXPECT_EQ(fake_apps().size(), ids.size()); |
| 500 ValidateAppReadyState(fake_apps(), true); | 483 ValidateAppReadyState(fake_apps(), true); |
| 501 | 484 |
| 502 // This recreates model and ARC apps will be read from prefs. | 485 // This recreates model and ARC apps will be read from prefs. |
| 503 bridge_service()->SetStopped(); | 486 arc_test()->StopArcInstance(); |
| 504 CreateBuilder(); | 487 CreateBuilder(); |
| 505 ValidateAppReadyState(fake_apps(), false); | 488 ValidateAppReadyState(fake_apps(), false); |
| 506 } | 489 } |
| 507 | 490 |
| 508 TEST_F(ArcAppModelBuilderTest, RestartPreserveShortcuts) { | 491 TEST_F(ArcAppModelBuilderTest, RestartPreserveShortcuts) { |
| 509 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 492 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 510 ASSERT_NE(nullptr, prefs); | 493 ASSERT_NE(nullptr, prefs); |
| 511 | 494 |
| 512 // Start from scratch and install shortcuts. | 495 // Start from scratch and install shortcuts. |
| 513 bridge_service()->SetReady(); | |
| 514 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 496 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
| 515 std::vector<std::string> ids = prefs->GetAppIds(); | 497 std::vector<std::string> ids = prefs->GetAppIds(); |
| 516 EXPECT_EQ(fake_apps().size(), ids.size()); | 498 EXPECT_EQ(fake_apps().size(), ids.size()); |
| 517 ValidateShortcutReadyState(fake_shortcuts(), true); | 499 ValidateShortcutReadyState(fake_shortcuts(), true); |
| 518 | 500 |
| 519 // This recreates model and ARC apps and shortcuts will be read from prefs. | 501 // This recreates model and ARC apps and shortcuts will be read from prefs. |
| 520 bridge_service()->SetStopped(); | 502 arc_test()->StopArcInstance(); |
| 521 CreateBuilder(); | 503 CreateBuilder(); |
| 522 ValidateShortcutReadyState(fake_shortcuts(), false); | 504 ValidateShortcutReadyState(fake_shortcuts(), false); |
| 523 } | 505 } |
| 524 | 506 |
| 525 TEST_F(ArcAppModelBuilderTest, LaunchApps) { | 507 TEST_F(ArcAppModelBuilderTest, LaunchApps) { |
| 526 // Disable attempts to dismiss app launcher view. | 508 // Disable attempts to dismiss app launcher view. |
| 527 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); | 509 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); |
| 528 | 510 |
| 529 bridge_service()->SetReady(); | |
| 530 app_instance()->RefreshAppList(); | 511 app_instance()->RefreshAppList(); |
| 531 app_instance()->SendRefreshAppList(fake_apps()); | 512 app_instance()->SendRefreshAppList(fake_apps()); |
| 532 | 513 |
| 533 // Simulate item activate. | 514 // Simulate item activate. |
| 534 const arc::mojom::AppInfo& app_first = fake_apps()[0]; | 515 const arc::mojom::AppInfo& app_first = fake_apps()[0]; |
| 535 const arc::mojom::AppInfo& app_last = fake_apps()[0]; | 516 const arc::mojom::AppInfo& app_last = fake_apps()[0]; |
| 536 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 517 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
| 537 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); | 518 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); |
| 538 ASSERT_NE(nullptr, item_first); | 519 ASSERT_NE(nullptr, item_first); |
| 539 ASSERT_NE(nullptr, item_last); | 520 ASSERT_NE(nullptr, item_last); |
| 540 item_first->Activate(0); | 521 item_first->Activate(0); |
| 541 app_instance()->WaitForIncomingMethodCall(); | |
| 542 item_last->Activate(0); | 522 item_last->Activate(0); |
| 543 app_instance()->WaitForIncomingMethodCall(); | |
| 544 item_first->Activate(0); | 523 item_first->Activate(0); |
| 545 app_instance()->WaitForIncomingMethodCall(); | |
| 546 | 524 |
| 547 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = | 525 const ScopedVector<arc::FakeAppInstance::Request>& launch_requests = |
| 548 app_instance()->launch_requests(); | 526 app_instance()->launch_requests(); |
| 549 ASSERT_EQ(3u, launch_requests.size()); | 527 ASSERT_EQ(3u, launch_requests.size()); |
| 550 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_first)); | 528 EXPECT_EQ(true, launch_requests[0]->IsForApp(app_first)); |
| 551 EXPECT_EQ(true, launch_requests[1]->IsForApp(app_last)); | 529 EXPECT_EQ(true, launch_requests[1]->IsForApp(app_last)); |
| 552 EXPECT_EQ(true, launch_requests[2]->IsForApp(app_first)); | 530 EXPECT_EQ(true, launch_requests[2]->IsForApp(app_first)); |
| 553 | 531 |
| 554 // Test an attempt to launch of a not-ready app. | 532 // Test an attempt to launch of a not-ready app. |
| 555 bridge_service()->SetStopped(); | 533 arc_test()->StopArcInstance(); |
| 556 item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 534 item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
| 557 ASSERT_NE(nullptr, item_first); | 535 ASSERT_NE(nullptr, item_first); |
| 558 size_t launch_request_count_before = app_instance()->launch_requests().size(); | 536 size_t launch_request_count_before = app_instance()->launch_requests().size(); |
| 559 item_first->Activate(0); | 537 item_first->Activate(0); |
| 560 // Number of launch requests must not change. | 538 // Number of launch requests must not change. |
| 561 EXPECT_EQ(launch_request_count_before, | 539 EXPECT_EQ(launch_request_count_before, |
| 562 app_instance()->launch_requests().size()); | 540 app_instance()->launch_requests().size()); |
| 563 } | 541 } |
| 564 | 542 |
| 565 TEST_F(ArcAppModelBuilderTest, LaunchShortcuts) { | 543 TEST_F(ArcAppModelBuilderTest, LaunchShortcuts) { |
| 566 // Disable attempts to dismiss app launcher view. | 544 // Disable attempts to dismiss app launcher view. |
| 567 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); | 545 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); |
| 568 | 546 |
| 569 bridge_service()->SetReady(); | |
| 570 app_instance()->RefreshAppList(); | 547 app_instance()->RefreshAppList(); |
| 571 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 548 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
| 572 | 549 |
| 573 // Simulate item activate. | 550 // Simulate item activate. |
| 574 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; | 551 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; |
| 575 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; | 552 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; |
| 576 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 553 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
| 577 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); | 554 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); |
| 578 ASSERT_NE(nullptr, item_first); | 555 ASSERT_NE(nullptr, item_first); |
| 579 ASSERT_NE(nullptr, item_last); | 556 ASSERT_NE(nullptr, item_last); |
| 580 item_first->Activate(0); | 557 item_first->Activate(0); |
| 581 app_instance()->WaitForIncomingMethodCall(); | |
| 582 item_last->Activate(0); | 558 item_last->Activate(0); |
| 583 app_instance()->WaitForIncomingMethodCall(); | |
| 584 item_first->Activate(0); | 559 item_first->Activate(0); |
| 585 app_instance()->WaitForIncomingMethodCall(); | |
| 586 | 560 |
| 587 const ScopedVector<mojo::String>& launch_intents = | 561 const ScopedVector<mojo::String>& launch_intents = |
| 588 app_instance()->launch_intents(); | 562 app_instance()->launch_intents(); |
| 589 ASSERT_EQ(3u, launch_intents.size()); | 563 ASSERT_EQ(3u, launch_intents.size()); |
| 590 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[0]); | 564 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[0]); |
| 591 EXPECT_EQ(true, app_last.intent_uri == *launch_intents[1]); | 565 EXPECT_EQ(true, app_last.intent_uri == *launch_intents[1]); |
| 592 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[2]); | 566 EXPECT_EQ(true, app_first.intent_uri == *launch_intents[2]); |
| 593 | 567 |
| 594 // Test an attempt to launch of a not-ready shortcut. | 568 // Test an attempt to launch of a not-ready shortcut. |
| 595 bridge_service()->SetStopped(); | 569 arc_test()->StopArcInstance(); |
| 596 item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 570 item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
| 597 ASSERT_NE(nullptr, item_first); | 571 ASSERT_NE(nullptr, item_first); |
| 598 size_t launch_request_count_before = app_instance()->launch_intents().size(); | 572 size_t launch_request_count_before = app_instance()->launch_intents().size(); |
| 599 item_first->Activate(0); | 573 item_first->Activate(0); |
| 600 // Number of launch requests must not change. | 574 // Number of launch requests must not change. |
| 601 EXPECT_EQ(launch_request_count_before, | 575 EXPECT_EQ(launch_request_count_before, |
| 602 app_instance()->launch_intents().size()); | 576 app_instance()->launch_intents().size()); |
| 603 } | 577 } |
| 604 | 578 |
| 605 TEST_F(ArcAppModelBuilderTest, RequestIcons) { | 579 TEST_F(ArcAppModelBuilderTest, RequestIcons) { |
| 606 // Make sure we are on UI thread. | 580 // Make sure we are on UI thread. |
| 607 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 581 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 608 | 582 |
| 609 bridge_service()->SetReady(); | |
| 610 app_instance()->RefreshAppList(); | 583 app_instance()->RefreshAppList(); |
| 611 app_instance()->SendRefreshAppList(fake_apps()); | 584 app_instance()->SendRefreshAppList(fake_apps()); |
| 612 | 585 |
| 613 // Validate that no icon exists at the beginning and request icon for | 586 // Validate that no icon exists at the beginning and request icon for |
| 614 // each supported scale factor. This will start asynchronous loading. | 587 // each supported scale factor. This will start asynchronous loading. |
| 615 uint32_t expected_mask = 0; | 588 uint32_t expected_mask = 0; |
| 616 const std::vector<ui::ScaleFactor>& scale_factors = | 589 const std::vector<ui::ScaleFactor>& scale_factors = |
| 617 ui::GetSupportedScaleFactors(); | 590 ui::GetSupportedScaleFactors(); |
| 618 for (auto& scale_factor : scale_factors) { | 591 for (auto& scale_factor : scale_factors) { |
| 619 expected_mask |= 1 << scale_factor; | 592 expected_mask |= 1 << scale_factor; |
| 620 for (auto& app : fake_apps()) { | 593 for (auto& app : fake_apps()) { |
| 621 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); | 594 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); |
| 622 ASSERT_NE(nullptr, app_item); | 595 ASSERT_NE(nullptr, app_item); |
| 623 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 596 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
| 624 app_item->icon().GetRepresentation(scale); | 597 app_item->icon().GetRepresentation(scale); |
| 625 } | 598 } |
| 626 } | 599 } |
| 627 | 600 |
| 628 // Process pending tasks. | 601 // Process pending tasks. |
| 629 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 602 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 630 base::RunLoop().RunUntilIdle(); | 603 base::RunLoop().RunUntilIdle(); |
| 631 // Normally just one call to RunUntilIdle() suffices to make sure | 604 // Normally just one call to RunUntilIdle() suffices to make sure |
| 632 // all RequestAppIcon() calls are delivered, but on slower machines | 605 // all RequestAppIcon() calls are delivered, but on slower machines |
| 633 // (especially when running under Valgrind), they might not get | 606 // (especially when running under Valgrind), they might not get |
| 634 // delivered on time. Wait for the remaining tasks individually. | 607 // delivered on time. Wait for the remaining tasks individually. |
| 635 const size_t expected_size = scale_factors.size() * fake_apps().size(); | 608 const size_t expected_size = scale_factors.size() * fake_apps().size(); |
| 636 while (app_instance()->icon_requests().size() < expected_size) { | |
| 637 app_instance()->WaitForIncomingMethodCall(); | |
| 638 } | |
| 639 | 609 |
| 640 // At this moment we should receive all requests for icon loading. | 610 // At this moment we should receive all requests for icon loading. |
| 641 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests = | 611 const ScopedVector<arc::FakeAppInstance::IconRequest>& icon_requests = |
| 642 app_instance()->icon_requests(); | 612 app_instance()->icon_requests(); |
| 643 EXPECT_EQ(expected_size, icon_requests.size()); | 613 EXPECT_EQ(expected_size, icon_requests.size()); |
| 644 std::map<std::string, uint32_t> app_masks; | 614 std::map<std::string, uint32_t> app_masks; |
| 645 for (size_t i = 0; i < icon_requests.size(); ++i) { | 615 for (size_t i = 0; i < icon_requests.size(); ++i) { |
| 646 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i]; | 616 const arc::FakeAppInstance::IconRequest* icon_request = icon_requests[i]; |
| 647 const std::string id = ArcAppListPrefs::GetAppId( | 617 const std::string id = ArcAppListPrefs::GetAppId( |
| 648 icon_request->package_name(), icon_request->activity()); | 618 icon_request->package_name(), icon_request->activity()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 659 const std::string id = ArcAppTest::GetAppId(app); | 629 const std::string id = ArcAppTest::GetAppId(app); |
| 660 ASSERT_NE(app_masks.find(id), app_masks.end()); | 630 ASSERT_NE(app_masks.find(id), app_masks.end()); |
| 661 EXPECT_EQ(app_masks[id], expected_mask); | 631 EXPECT_EQ(app_masks[id], expected_mask); |
| 662 } | 632 } |
| 663 } | 633 } |
| 664 | 634 |
| 665 TEST_F(ArcAppModelBuilderTest, RequestShortcutIcons) { | 635 TEST_F(ArcAppModelBuilderTest, RequestShortcutIcons) { |
| 666 // Make sure we are on UI thread. | 636 // Make sure we are on UI thread. |
| 667 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 637 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 668 | 638 |
| 669 bridge_service()->SetReady(); | |
| 670 const arc::mojom::ShortcutInfo& shortcut = fake_shortcuts()[0]; | 639 const arc::mojom::ShortcutInfo& shortcut = fake_shortcuts()[0]; |
| 671 app_instance()->SendInstallShortcut(shortcut); | 640 app_instance()->SendInstallShortcut(shortcut); |
| 672 | 641 |
| 673 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 642 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 674 ASSERT_NE(nullptr, prefs); | 643 ASSERT_NE(nullptr, prefs); |
| 675 | 644 |
| 676 // Validate that no icon exists at the beginning and request icon for | 645 // Validate that no icon exists at the beginning and request icon for |
| 677 // each supported scale factor. This will start asynchronous loading. | 646 // each supported scale factor. This will start asynchronous loading. |
| 678 uint32_t expected_mask = 0; | 647 uint32_t expected_mask = 0; |
| 679 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(shortcut)); | 648 ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(shortcut)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 const base::FilePath icon_path = | 688 const base::FilePath icon_path = |
| 720 prefs->GetIconPath(ArcAppTest::GetAppId(shortcut), scale_factor); | 689 prefs->GetIconPath(ArcAppTest::GetAppId(shortcut), scale_factor); |
| 721 EXPECT_EQ(true, base::PathExists(icon_path)); | 690 EXPECT_EQ(true, base::PathExists(icon_path)); |
| 722 } | 691 } |
| 723 } | 692 } |
| 724 | 693 |
| 725 TEST_F(ArcAppModelBuilderTest, InstallIcon) { | 694 TEST_F(ArcAppModelBuilderTest, InstallIcon) { |
| 726 // Make sure we are on UI thread. | 695 // Make sure we are on UI thread. |
| 727 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 696 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 728 | 697 |
| 729 bridge_service()->SetReady(); | |
| 730 app_instance()->RefreshAppList(); | 698 app_instance()->RefreshAppList(); |
| 731 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 699 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
| 732 fake_apps().begin(), fake_apps().begin() + 1)); | 700 fake_apps().begin(), fake_apps().begin() + 1)); |
| 733 const arc::mojom::AppInfo& app = fake_apps()[0]; | 701 const arc::mojom::AppInfo& app = fake_apps()[0]; |
| 734 | 702 |
| 735 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 703 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 736 ASSERT_NE(nullptr, prefs); | 704 ASSERT_NE(nullptr, prefs); |
| 737 | 705 |
| 738 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; | 706 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; |
| 739 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 707 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 770 std::string icon_data; | 738 std::string icon_data; |
| 771 // Read the file from disk and compare with reference data. | 739 // Read the file from disk and compare with reference data. |
| 772 EXPECT_EQ(true, base::ReadFileToString(icon_path, &icon_data)); | 740 EXPECT_EQ(true, base::ReadFileToString(icon_path, &icon_data)); |
| 773 ASSERT_EQ(icon_data, png_data); | 741 ASSERT_EQ(icon_data, png_data); |
| 774 } | 742 } |
| 775 | 743 |
| 776 TEST_F(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) { | 744 TEST_F(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) { |
| 777 // Make sure we are on UI thread. | 745 // Make sure we are on UI thread. |
| 778 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 746 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 779 | 747 |
| 780 bridge_service()->SetReady(); | |
| 781 app_instance()->RefreshAppList(); | 748 app_instance()->RefreshAppList(); |
| 782 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 749 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
| 783 fake_apps().begin(), fake_apps().begin() + 1)); | 750 fake_apps().begin(), fake_apps().begin() + 1)); |
| 784 const arc::mojom::AppInfo& app = fake_apps()[0]; | 751 const arc::mojom::AppInfo& app = fake_apps()[0]; |
| 785 | 752 |
| 786 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 753 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 787 ASSERT_NE(nullptr, prefs); | 754 ASSERT_NE(nullptr, prefs); |
| 788 | 755 |
| 789 const std::string app_id = ArcAppTest::GetAppId(app); | 756 const std::string app_id = ArcAppTest::GetAppId(app); |
| 790 const base::FilePath app_path = prefs->GetAppPath(app_id); | 757 const base::FilePath app_path = prefs->GetAppPath(app_id); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 808 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); | 775 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); |
| 809 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 776 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 810 base::RunLoop().RunUntilIdle(); | 777 base::RunLoop().RunUntilIdle(); |
| 811 EXPECT_EQ(true, !base::PathExists(app_path)); | 778 EXPECT_EQ(true, !base::PathExists(app_path)); |
| 812 } | 779 } |
| 813 | 780 |
| 814 TEST_F(ArcAppModelBuilderTest, LastLaunchTime) { | 781 TEST_F(ArcAppModelBuilderTest, LastLaunchTime) { |
| 815 // Make sure we are on UI thread. | 782 // Make sure we are on UI thread. |
| 816 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 783 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 817 | 784 |
| 818 bridge_service()->SetReady(); | |
| 819 app_instance()->RefreshAppList(); | 785 app_instance()->RefreshAppList(); |
| 820 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 786 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
| 821 fake_apps().begin(), fake_apps().begin() + 2)); | 787 fake_apps().begin(), fake_apps().begin() + 2)); |
| 822 const arc::mojom::AppInfo& app1 = fake_apps()[0]; | 788 const arc::mojom::AppInfo& app1 = fake_apps()[0]; |
| 823 const arc::mojom::AppInfo& app2 = fake_apps()[1]; | 789 const arc::mojom::AppInfo& app2 = fake_apps()[1]; |
| 824 const std::string id1 = ArcAppTest::GetAppId(app1); | 790 const std::string id1 = ArcAppTest::GetAppId(app1); |
| 825 const std::string id2 = ArcAppTest::GetAppId(app2); | 791 const std::string id2 = ArcAppTest::GetAppId(app2); |
| 826 | 792 |
| 827 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 793 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 828 ASSERT_NE(nullptr, prefs); | 794 ASSERT_NE(nullptr, prefs); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 855 ASSERT_GE(time_after, app_info->last_launch_time); | 821 ASSERT_GE(time_after, app_info->last_launch_time); |
| 856 } | 822 } |
| 857 | 823 |
| 858 TEST_F(ArcAppModelBuilderTest, IconLoader) { | 824 TEST_F(ArcAppModelBuilderTest, IconLoader) { |
| 859 // Validating decoded content does not fit well for unit tests. | 825 // Validating decoded content does not fit well for unit tests. |
| 860 ArcAppIcon::DisableSafeDecodingForTesting(); | 826 ArcAppIcon::DisableSafeDecodingForTesting(); |
| 861 | 827 |
| 862 const arc::mojom::AppInfo& app = fake_apps()[0]; | 828 const arc::mojom::AppInfo& app = fake_apps()[0]; |
| 863 const std::string app_id = ArcAppTest::GetAppId(app); | 829 const std::string app_id = ArcAppTest::GetAppId(app); |
| 864 | 830 |
| 865 bridge_service()->SetReady(); | 831 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
| 832 ASSERT_NE(nullptr, prefs); |
| 833 |
| 866 app_instance()->RefreshAppList(); | 834 app_instance()->RefreshAppList(); |
| 867 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 835 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
| 868 fake_apps().begin(), fake_apps().begin() + 1)); | 836 fake_apps().begin(), fake_apps().begin() + 1)); |
| 869 | 837 |
| 870 FakeAppIconLoaderDelegate delegate; | 838 FakeAppIconLoaderDelegate delegate; |
| 871 ArcAppIconLoader icon_loader(profile(), | 839 ArcAppIconLoader icon_loader(profile(), |
| 872 app_list::kListIconSize, | 840 app_list::kListIconSize, |
| 873 &delegate); | 841 &delegate); |
| 874 EXPECT_EQ(0UL, delegate.update_image_cnt()); | 842 EXPECT_EQ(0UL, delegate.update_image_cnt()); |
| 875 icon_loader.FetchImage(app_id); | 843 icon_loader.FetchImage(app_id); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 const arc::mojom::AppInfo& app2 = fake_apps()[1]; | 880 const arc::mojom::AppInfo& app2 = fake_apps()[1]; |
| 913 const arc::mojom::AppInfo& app3 = fake_apps()[2]; | 881 const arc::mojom::AppInfo& app3 = fake_apps()[2]; |
| 914 const std::string id1 = ArcAppTest::GetAppId(app1); | 882 const std::string id1 = ArcAppTest::GetAppId(app1); |
| 915 const std::string id2 = ArcAppTest::GetAppId(app2); | 883 const std::string id2 = ArcAppTest::GetAppId(app2); |
| 916 const std::string id3 = ArcAppTest::GetAppId(app3); | 884 const std::string id3 = ArcAppTest::GetAppId(app3); |
| 917 | 885 |
| 918 ArcAppLauncher launcher1(profile(), id1, true); | 886 ArcAppLauncher launcher1(profile(), id1, true); |
| 919 EXPECT_FALSE(launcher1.app_launched()); | 887 EXPECT_FALSE(launcher1.app_launched()); |
| 920 EXPECT_TRUE(prefs->HasObserver(&launcher1)); | 888 EXPECT_TRUE(prefs->HasObserver(&launcher1)); |
| 921 | 889 |
| 922 bridge_service()->SetReady(); | |
| 923 | |
| 924 ArcAppLauncher launcher3(profile(), id3, true); | 890 ArcAppLauncher launcher3(profile(), id3, true); |
| 925 EXPECT_FALSE(launcher1.app_launched()); | 891 EXPECT_FALSE(launcher1.app_launched()); |
| 926 EXPECT_TRUE(prefs->HasObserver(&launcher1)); | 892 EXPECT_TRUE(prefs->HasObserver(&launcher1)); |
| 927 EXPECT_FALSE(launcher3.app_launched()); | 893 EXPECT_FALSE(launcher3.app_launched()); |
| 928 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 894 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
| 929 | 895 |
| 930 EXPECT_EQ(0u, app_instance()->launch_requests().size()); | 896 EXPECT_EQ(0u, app_instance()->launch_requests().size()); |
| 931 | 897 |
| 932 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin(), | 898 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin(), |
| 933 fake_apps().begin() + 2); | 899 fake_apps().begin() + 2); |
| 934 app_instance()->SendRefreshAppList(apps); | 900 app_instance()->SendRefreshAppList(apps); |
| 935 | 901 |
| 936 EXPECT_TRUE(launcher1.app_launched()); | 902 EXPECT_TRUE(launcher1.app_launched()); |
| 937 app_instance()->WaitForIncomingMethodCall(); | |
| 938 ASSERT_EQ(1u, app_instance()->launch_requests().size()); | 903 ASSERT_EQ(1u, app_instance()->launch_requests().size()); |
| 939 EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(app1)); | 904 EXPECT_TRUE(app_instance()->launch_requests()[0]->IsForApp(app1)); |
| 940 EXPECT_FALSE(launcher3.app_launched()); | 905 EXPECT_FALSE(launcher3.app_launched()); |
| 941 EXPECT_FALSE(prefs->HasObserver(&launcher1)); | 906 EXPECT_FALSE(prefs->HasObserver(&launcher1)); |
| 942 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 907 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
| 943 | 908 |
| 944 ArcAppLauncher launcher2(profile(), id2, true); | 909 ArcAppLauncher launcher2(profile(), id2, true); |
| 945 EXPECT_TRUE(launcher2.app_launched()); | 910 EXPECT_TRUE(launcher2.app_launched()); |
| 946 app_instance()->WaitForIncomingMethodCall(); | |
| 947 EXPECT_FALSE(prefs->HasObserver(&launcher2)); | 911 EXPECT_FALSE(prefs->HasObserver(&launcher2)); |
| 948 ASSERT_EQ(2u, app_instance()->launch_requests().size()); | 912 ASSERT_EQ(2u, app_instance()->launch_requests().size()); |
| 949 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); | 913 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); |
| 950 } | 914 } |
| OLD | NEW |