Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 model_observer_.reset(new TestShelfModelObserver); | 318 model_observer_.reset(new TestShelfModelObserver); |
| 319 model_->AddObserver(model_observer_.get()); | 319 model_->AddObserver(model_observer_.get()); |
| 320 | 320 |
| 321 base::DictionaryValue manifest; | 321 base::DictionaryValue manifest; |
| 322 manifest.SetString(extensions::manifest_keys::kName, | 322 manifest.SetString(extensions::manifest_keys::kName, |
| 323 "launcher controller test extension"); | 323 "launcher controller test extension"); |
| 324 manifest.SetString(extensions::manifest_keys::kVersion, "1"); | 324 manifest.SetString(extensions::manifest_keys::kVersion, "1"); |
| 325 manifest.SetString(extensions::manifest_keys::kDescription, | 325 manifest.SetString(extensions::manifest_keys::kDescription, |
| 326 "for testing pinned apps"); | 326 "for testing pinned apps"); |
| 327 | 327 |
| 328 base::DictionaryValue manifest_platform_app; | |
| 329 manifest_platform_app.SetString(extensions::manifest_keys::kName, | |
| 330 "launcher controller test platform app"); | |
| 331 manifest_platform_app.SetString(extensions::manifest_keys::kVersion, "1"); | |
| 332 manifest_platform_app.SetString(extensions::manifest_keys::kDescription, | |
| 333 "for testing pinned platform apps"); | |
| 334 manifest_platform_app.SetString(extensions::manifest_keys::kApp, "true"); | |
| 335 manifest_platform_app.Set(extensions::manifest_keys::kPlatformAppBackground, | |
| 336 new base::DictionaryValue()); | |
| 337 base::ListValue* scripts = new base::ListValue(); | |
| 338 scripts->AppendString("main.js"); | |
| 339 manifest_platform_app.Set( | |
| 340 extensions::manifest_keys::kPlatformAppBackgroundScripts, scripts); | |
| 341 | |
| 328 extensions::TestExtensionSystem* extension_system( | 342 extensions::TestExtensionSystem* extension_system( |
| 329 static_cast<extensions::TestExtensionSystem*>( | 343 static_cast<extensions::TestExtensionSystem*>( |
| 330 extensions::ExtensionSystem::Get(profile()))); | 344 extensions::ExtensionSystem::Get(profile()))); |
| 331 extension_service_ = extension_system->CreateExtensionService( | 345 extension_service_ = extension_system->CreateExtensionService( |
| 332 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); | 346 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 333 extension_service_->Init(); | 347 extension_service_->Init(); |
| 334 | 348 |
| 335 if (auto_start_arc_test_) | 349 if (auto_start_arc_test_) |
| 336 arc_test_.SetUp(profile()); | 350 arc_test_.SetUp(profile()); |
| 337 | 351 |
| 338 // Wait until |extension_system| is signaled as started. | 352 // Wait until |extension_system| is signaled as started. |
| 339 base::RunLoop run_loop; | 353 base::RunLoop run_loop; |
| 340 extension_system->ready().Post(FROM_HERE, run_loop.QuitClosure()); | 354 extension_system->ready().Post(FROM_HERE, run_loop.QuitClosure()); |
| 341 run_loop.Run(); | 355 run_loop.Run(); |
| 342 | 356 |
| 343 app_service_ = | 357 app_service_ = |
| 344 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 358 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
| 345 StartAppSyncService(syncer::SyncDataList()); | 359 StartAppSyncService(syncer::SyncDataList()); |
| 346 | 360 |
| 347 std::string error; | 361 std::string error; |
| 348 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 362 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 349 manifest, | 363 manifest, Extension::NO_FLAGS, |
| 350 Extension::NO_FLAGS, | 364 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", &error); |
| 351 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | |
| 352 &error); | |
| 353 extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 365 extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 354 manifest, | 366 manifest, Extension::NO_FLAGS, |
| 355 Extension::NO_FLAGS, | 367 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", &error); |
| 356 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", | |
| 357 &error); | |
| 358 // Fake gmail extension. | 368 // Fake gmail extension. |
| 359 base::DictionaryValue manifest_gmail; | 369 base::DictionaryValue manifest_gmail; |
| 360 manifest_gmail.SetString(extensions::manifest_keys::kName, | 370 manifest_gmail.SetString(extensions::manifest_keys::kName, |
| 361 "Gmail launcher controller test extension"); | 371 "Gmail launcher controller test extension"); |
| 362 manifest_gmail.SetString(extensions::manifest_keys::kVersion, "1"); | 372 manifest_gmail.SetString(extensions::manifest_keys::kVersion, "1"); |
| 363 manifest_gmail.SetString(extensions::manifest_keys::kDescription, | 373 manifest_gmail.SetString(extensions::manifest_keys::kDescription, |
| 364 "for testing pinned Gmail"); | 374 "for testing pinned Gmail"); |
| 365 manifest_gmail.SetString(extensions::manifest_keys::kLaunchWebURL, | 375 manifest_gmail.SetString(extensions::manifest_keys::kLaunchWebURL, |
| 366 kGmailLaunchURL); | 376 kGmailLaunchURL); |
| 367 base::ListValue* list = new base::ListValue(); | 377 base::ListValue* list = new base::ListValue(); |
| 368 list->AppendString("*://mail.google.com/mail/ca"); | 378 list->AppendString("*://mail.google.com/mail/ca"); |
| 369 manifest_gmail.Set(extensions::manifest_keys::kWebURLs, list); | 379 manifest_gmail.Set(extensions::manifest_keys::kWebURLs, list); |
| 370 | 380 |
| 371 extension3_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 381 extension3_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 372 manifest_gmail, | 382 manifest_gmail, Extension::NO_FLAGS, |
| 373 Extension::NO_FLAGS, | 383 extension_misc::kGmailAppId, &error); |
| 374 extension_misc::kGmailAppId, | |
| 375 &error); | |
| 376 | 384 |
| 377 // Fake google docs extension. | 385 // Fake google docs extension. |
| 378 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 386 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 379 manifest, | 387 manifest, Extension::NO_FLAGS, |
| 380 Extension::NO_FLAGS, | 388 extension_misc::kGoogleDocAppId, &error); |
| 381 extension_misc::kGoogleDocAppId, | |
| 382 &error); | |
| 383 extension5_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 389 extension5_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 384 manifest, | 390 manifest, Extension::NO_FLAGS, |
| 385 Extension::NO_FLAGS, | 391 "cccccccccccccccccccccccccccccccc", &error); |
| 386 "cccccccccccccccccccccccccccccccc", | |
| 387 &error); | |
| 388 extension6_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 392 extension6_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 389 manifest, | 393 manifest, Extension::NO_FLAGS, |
| 390 Extension::NO_FLAGS, | 394 "dddddddddddddddddddddddddddddddd", &error); |
| 391 "dddddddddddddddddddddddddddddddd", | |
| 392 &error); | |
| 393 extension7_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 395 extension7_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 394 manifest, | 396 manifest, Extension::NO_FLAGS, |
| 395 Extension::NO_FLAGS, | 397 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", &error); |
| 396 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", | |
| 397 &error); | |
| 398 extension8_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 398 extension8_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 399 manifest, | 399 manifest, Extension::NO_FLAGS, |
| 400 Extension::NO_FLAGS, | 400 "ffffffffffffffffffffffffffffffff", &error); |
| 401 "ffffffffffffffffffffffffffffffff", | 401 extension_platform_app_ = Extension::Create( |
| 402 &error); | 402 base::FilePath(), Manifest::UNPACKED, manifest_platform_app, |
| 403 Extension::NO_FLAGS, "gggggggggggggggggggggggggggggggg", &error); | |
| 403 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 404 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 404 manifest, Extension::NO_FLAGS, | 405 manifest, Extension::NO_FLAGS, |
| 405 ArcSupportHost::kHostAppId, &error); | 406 ArcSupportHost::kHostAppId, &error); |
| 406 } | 407 } |
| 407 | 408 |
| 408 // Creates a running V2 app (not pinned) of type |app_id|. | 409 // Creates a running platform V2 app (not pinned) of type |app_id|. |
| 409 virtual void CreateRunningV2App(const std::string& app_id) { | 410 virtual void CreateRunningV2App(const std::string& app_id) { |
| 410 DCHECK(!test_controller_); | 411 DCHECK(!test_controller_); |
| 411 ash::ShelfID id = | 412 ash::ShelfID id = |
| 412 launcher_controller_->CreateAppShortcutLauncherItemWithType( | 413 launcher_controller_->CreateAppShortcutLauncherItemWithType( |
| 413 ash::launcher::AppLauncherId(app_id), model_->item_count(), | 414 ash::launcher::AppLauncherId(app_id), model_->item_count(), |
| 414 ash::TYPE_PLATFORM_APP); | 415 ash::TYPE_APP); |
| 415 DCHECK(id); | 416 DCHECK(id); |
| 416 // Change the created launcher controller into a V2 app controller. | 417 // Change the created launcher controller into a V2 app controller. |
| 417 test_controller_ = new TestV2AppLauncherItemController(app_id, | 418 test_controller_ = new TestV2AppLauncherItemController(app_id, |
| 418 launcher_controller_.get()); | 419 launcher_controller_.get()); |
| 419 launcher_controller_->SetItemController(id, test_controller_); | 420 launcher_controller_->SetItemController(id, test_controller_); |
| 421 DCHECK(launcher_controller_->IsPlatformApp(id)); | |
| 420 } | 422 } |
| 421 | 423 |
| 422 // Sets the stage for a multi user test. | 424 // Sets the stage for a multi user test. |
| 423 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, | 425 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, |
| 424 syncer::SyncChangeList* user_b) { | 426 syncer::SyncChangeList* user_b) { |
| 425 InitLauncherController(); | 427 InitLauncherController(); |
| 426 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 428 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 427 | 429 |
| 428 // Set an empty pinned pref to begin with. | 430 // Set an empty pinned pref to begin with. |
| 429 syncer::SyncChangeList sync_list; | 431 syncer::SyncChangeList sync_list; |
| 430 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); | 432 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); |
| 431 SendPinChanges(sync_list, true); | 433 SendPinChanges(sync_list, true); |
| 432 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 434 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 433 | 435 |
| 434 // Assume all applications have been added already. | 436 // Assume all applications have been added already. |
| 435 extension_service_->AddExtension(extension1_.get()); | 437 extension_service_->AddExtension(extension1_.get()); |
| 436 extension_service_->AddExtension(extension2_.get()); | 438 extension_service_->AddExtension(extension2_.get()); |
| 437 extension_service_->AddExtension(extension3_.get()); | 439 extension_service_->AddExtension(extension3_.get()); |
| 438 extension_service_->AddExtension(extension4_.get()); | 440 extension_service_->AddExtension(extension4_.get()); |
| 439 extension_service_->AddExtension(extension5_.get()); | 441 extension_service_->AddExtension(extension5_.get()); |
| 440 extension_service_->AddExtension(extension6_.get()); | 442 extension_service_->AddExtension(extension6_.get()); |
| 441 extension_service_->AddExtension(extension7_.get()); | 443 extension_service_->AddExtension(extension7_.get()); |
| 442 extension_service_->AddExtension(extension8_.get()); | 444 extension_service_->AddExtension(extension8_.get()); |
| 445 extension_service_->AddExtension(extension_platform_app_.get()); | |
| 443 // There should be nothing in the list by now. | 446 // There should be nothing in the list by now. |
| 444 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 447 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 445 | 448 |
| 446 // Set user a preferences. | 449 // Set user a preferences. |
| 447 InsertAddPinChange(user_a, 0, extension1_->id()); | 450 InsertAddPinChange(user_a, 0, extension1_->id()); |
| 448 InsertAddPinChange(user_a, 1, extension2_->id()); | 451 InsertAddPinChange(user_a, 1, extension2_->id()); |
| 449 InsertAddPinChange(user_a, 2, extension3_->id()); | 452 InsertAddPinChange(user_a, 2, extension3_->id()); |
| 450 InsertAddPinChange(user_a, 3, extension4_->id()); | 453 InsertAddPinChange(user_a, 3, extension_platform_app_->id()); |
| 451 InsertAddPinChange(user_a, 4, extension5_->id()); | 454 InsertAddPinChange(user_a, 4, extension4_->id()); |
| 452 InsertAddPinChange(user_a, 5, extension6_->id()); | 455 InsertAddPinChange(user_a, 5, extension5_->id()); |
| 453 InsertAddPinChange(user_a, 6, extension_misc::kChromeAppId); | 456 InsertAddPinChange(user_a, 6, extension_misc::kChromeAppId); |
| 454 | 457 |
| 455 // Set user b preferences. | 458 // Set user b preferences. |
| 456 InsertAddPinChange(user_b, 0, extension7_->id()); | 459 InsertAddPinChange(user_b, 0, extension6_->id()); |
| 457 InsertAddPinChange(user_b, 1, extension8_->id()); | 460 InsertAddPinChange(user_b, 1, extension7_->id()); |
| 458 InsertAddPinChange(user_b, 2, extension_misc::kChromeAppId); | 461 InsertAddPinChange(user_b, 2, extension8_->id()); |
| 462 InsertAddPinChange(user_b, 3, extension_misc::kChromeAppId); | |
| 459 } | 463 } |
| 460 | 464 |
| 461 void TearDown() override { | 465 void TearDown() override { |
| 462 arc_test_.TearDown(); | 466 arc_test_.TearDown(); |
| 463 model_->RemoveObserver(model_observer_.get()); | 467 model_->RemoveObserver(model_observer_.get()); |
| 464 model_observer_.reset(); | 468 model_observer_.reset(); |
| 465 launcher_controller_.reset(); | 469 launcher_controller_.reset(); |
| 466 BrowserWithTestWindowTest::TearDown(); | 470 BrowserWithTestWindowTest::TearDown(); |
| 467 } | 471 } |
| 468 | 472 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 // Get the setup of the currently shown launcher items in one string. | 680 // Get the setup of the currently shown launcher items in one string. |
| 677 // Each pinned element will start with a big letter, each running but not | 681 // Each pinned element will start with a big letter, each running but not |
| 678 // pinned V1 app will start with a small letter and each running but not | 682 // pinned V1 app will start with a small letter and each running but not |
| 679 // pinned V2 app will start with a '*' + small letter. | 683 // pinned V2 app will start with a '*' + small letter. |
| 680 std::string GetPinnedAppStatus() { | 684 std::string GetPinnedAppStatus() { |
| 681 std::string result; | 685 std::string result; |
| 682 for (int i = 0; i < model_->item_count(); i++) { | 686 for (int i = 0; i < model_->item_count(); i++) { |
| 683 if (!result.empty()) | 687 if (!result.empty()) |
| 684 result.append(", "); | 688 result.append(", "); |
| 685 switch (model_->items()[i].type) { | 689 switch (model_->items()[i].type) { |
| 686 case ash::TYPE_PLATFORM_APP: | 690 case ash::TYPE_APP: { |
| 687 result += "*"; | 691 if (launcher_controller_->IsPlatformApp(model_->items()[i].id)) |
| 688 // FALLTHROUGH | 692 result += "*"; |
| 689 case ash::TYPE_WINDOWED_APP: { | |
| 690 const std::string& app = | 693 const std::string& app = |
| 691 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); | 694 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); |
| 692 if (app == extension1_->id()) { | 695 EXPECT_FALSE(launcher_controller_->IsAppPinned(app)); |
| 693 result += "app1"; | 696 if (app == extension1_->id()) { |
| 694 EXPECT_FALSE( | 697 result += "app1"; |
| 695 launcher_controller_->IsAppPinned(extension1_->id())); | 698 } else if (app == extension2_->id()) { |
| 696 } else if (app == extension2_->id()) { | 699 result += "app2"; |
| 697 result += "app2"; | 700 } else if (app == extension3_->id()) { |
| 698 EXPECT_FALSE( | 701 result += "app3"; |
| 699 launcher_controller_->IsAppPinned(extension2_->id())); | 702 } else if (app == extension4_->id()) { |
| 700 } else if (app == extension3_->id()) { | 703 result += "app4"; |
| 701 result += "app3"; | 704 } else if (app == extension5_->id()) { |
| 702 EXPECT_FALSE( | 705 result += "app5"; |
| 703 launcher_controller_->IsAppPinned(extension3_->id())); | 706 } else if (app == extension6_->id()) { |
| 704 } else if (app == extension4_->id()) { | 707 result += "app6"; |
| 705 result += "app4"; | 708 } else if (app == extension7_->id()) { |
| 706 EXPECT_FALSE( | 709 result += "app7"; |
| 707 launcher_controller_->IsAppPinned(extension4_->id())); | 710 } else if (app == extension8_->id()) { |
| 708 } else if (app == extension5_->id()) { | 711 result += "app8"; |
| 709 result += "app5"; | 712 } else if (app == extension_platform_app_->id()) { |
| 710 EXPECT_FALSE( | 713 result += "platform_app"; |
| 711 launcher_controller_->IsAppPinned(extension5_->id())); | 714 } else { |
| 712 } else if (app == extension6_->id()) { | 715 result += "unknown"; |
| 713 result += "app6"; | |
| 714 EXPECT_FALSE( | |
| 715 launcher_controller_->IsAppPinned(extension6_->id())); | |
| 716 } else if (app == extension7_->id()) { | |
| 717 result += "app7"; | |
| 718 EXPECT_FALSE( | |
| 719 launcher_controller_->IsAppPinned(extension7_->id())); | |
| 720 } else if (app == extension8_->id()) { | |
| 721 result += "app8"; | |
| 722 EXPECT_FALSE( | |
| 723 launcher_controller_->IsAppPinned(extension8_->id())); | |
| 724 } else { | |
| 725 result += "unknown"; | |
| 726 } | |
| 727 break; | |
| 728 } | 716 } |
| 717 break; | |
| 718 } | |
| 729 case ash::TYPE_APP_SHORTCUT: { | 719 case ash::TYPE_APP_SHORTCUT: { |
| 720 if (launcher_controller_->IsPlatformApp(model_->items()[i].id)) | |
| 721 result += "*"; | |
| 730 const std::string& app = | 722 const std::string& app = |
| 731 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); | 723 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); |
| 732 if (app == extension1_->id()) { | 724 EXPECT_TRUE(launcher_controller_->IsAppPinned(app)); |
| 733 result += "App1"; | 725 if (app == extension1_->id()) { |
| 734 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 726 result += "App1"; |
| 735 } else if (app == extension2_->id()) { | 727 } else if (app == extension2_->id()) { |
| 736 result += "App2"; | 728 result += "App2"; |
| 737 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 729 } else if (app == extension3_->id()) { |
| 738 } else if (app == extension3_->id()) { | 730 result += "App3"; |
| 739 result += "App3"; | 731 } else if (app == extension4_->id()) { |
| 740 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 732 result += "App4"; |
| 741 } else if (app == extension4_->id()) { | 733 } else if (app == extension5_->id()) { |
| 742 result += "App4"; | 734 result += "App5"; |
| 743 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); | 735 } else if (app == extension6_->id()) { |
| 744 } else if (app == extension5_->id()) { | 736 result += "App6"; |
| 745 result += "App5"; | 737 } else if (app == extension7_->id()) { |
| 746 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension5_->id())); | 738 result += "App7"; |
| 747 } else if (app == extension6_->id()) { | 739 } else if (app == extension8_->id()) { |
| 748 result += "App6"; | 740 result += "App8"; |
| 749 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension6_->id())); | 741 } else if (app == extension_platform_app_->id()) { |
| 750 } else if (app == extension7_->id()) { | 742 result += "Platform_App"; |
| 751 result += "App7"; | 743 } else if (app == arc_support_host_->id()) { |
| 752 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension7_->id())); | 744 result += "Play Store"; |
| 753 } else if (app == extension8_->id()) { | 745 } else { |
| 754 result += "App8"; | 746 bool arc_app_found = false; |
| 755 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension8_->id())); | 747 for (const auto& arc_app : arc_test_.fake_apps()) { |
| 756 } else if (app == arc_support_host_->id()) { | 748 if (app == ArcAppTest::GetAppId(arc_app)) { |
| 757 result += "Play Store"; | 749 result += arc_app.name; |
| 758 EXPECT_TRUE( | 750 arc_app_found = true; |
| 759 launcher_controller_->IsAppPinned(arc_support_host_->id())); | 751 break; |
| 760 } else { | |
| 761 bool arc_app_found = false; | |
| 762 for (const auto& arc_app : arc_test_.fake_apps()) { | |
| 763 if (app == ArcAppTest::GetAppId(arc_app)) { | |
| 764 result += arc_app.name; | |
| 765 arc_app_found = true; | |
| 766 break; | |
| 767 } | |
| 768 } | 752 } |
| 769 if (!arc_app_found) | |
| 770 result += "unknown"; | |
| 771 } | 753 } |
| 772 break; | 754 if (!arc_app_found) |
| 755 result += "unknown"; | |
| 773 } | 756 } |
| 757 break; | |
| 758 } | |
| 774 case ash::TYPE_BROWSER_SHORTCUT: | 759 case ash::TYPE_BROWSER_SHORTCUT: |
| 775 result += "Chrome"; | 760 result += "Chrome"; |
| 776 break; | 761 break; |
| 777 case ash::TYPE_APP_LIST: | 762 case ash::TYPE_APP_LIST: |
| 778 result += "AppList"; | 763 result += "AppList"; |
| 779 break; | 764 break; |
| 780 default: | 765 default: |
| 781 result += "Unknown"; | 766 result += "Unknown"; |
| 782 break; | 767 break; |
| 783 } | 768 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 | 875 |
| 891 // Needed for extension service & friends to work. | 876 // Needed for extension service & friends to work. |
| 892 scoped_refptr<Extension> extension1_; | 877 scoped_refptr<Extension> extension1_; |
| 893 scoped_refptr<Extension> extension2_; | 878 scoped_refptr<Extension> extension2_; |
| 894 scoped_refptr<Extension> extension3_; | 879 scoped_refptr<Extension> extension3_; |
| 895 scoped_refptr<Extension> extension4_; | 880 scoped_refptr<Extension> extension4_; |
| 896 scoped_refptr<Extension> extension5_; | 881 scoped_refptr<Extension> extension5_; |
| 897 scoped_refptr<Extension> extension6_; | 882 scoped_refptr<Extension> extension6_; |
| 898 scoped_refptr<Extension> extension7_; | 883 scoped_refptr<Extension> extension7_; |
| 899 scoped_refptr<Extension> extension8_; | 884 scoped_refptr<Extension> extension8_; |
| 885 scoped_refptr<Extension> extension_platform_app_; | |
| 900 scoped_refptr<Extension> arc_support_host_; | 886 scoped_refptr<Extension> arc_support_host_; |
| 901 | 887 |
| 902 ArcAppTest arc_test_; | 888 ArcAppTest arc_test_; |
| 903 bool auto_start_arc_test_ = false; | 889 bool auto_start_arc_test_ = false; |
| 904 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; | 890 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; |
| 905 std::unique_ptr<TestShelfModelObserver> model_observer_; | 891 std::unique_ptr<TestShelfModelObserver> model_observer_; |
| 906 ash::ShelfModel* model_ = nullptr; | 892 ash::ShelfModel* model_ = nullptr; |
| 907 std::unique_ptr<TestingProfileManager> profile_manager_; | 893 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 908 | 894 |
| 909 // |item_delegate_manager_| owns |test_controller_|. | 895 // |item_delegate_manager_| owns |test_controller_|. |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1571 UnloadedExtensionInfo::REASON_UPDATE); | 1557 UnloadedExtensionInfo::REASON_UPDATE); |
| 1572 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 1558 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
| 1573 } | 1559 } |
| 1574 | 1560 |
| 1575 // Check that simple locking of an application will 'create' a launcher item. | 1561 // Check that simple locking of an application will 'create' a launcher item. |
| 1576 TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) { | 1562 TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) { |
| 1577 InitLauncherController(); | 1563 InitLauncherController(); |
| 1578 // Model should only contain the browser shortcut and app list items. | 1564 // Model should only contain the browser shortcut and app list items. |
| 1579 EXPECT_EQ(2, model_->item_count()); | 1565 EXPECT_EQ(2, model_->item_count()); |
| 1580 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1566 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1581 EXPECT_FALSE( | 1567 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
|
James Cook
2016/11/28 22:57:47
kInvalidShelfId?
msw
2016/11/28 23:47:41
Yeah... I was using 0 to follow other checks in th
| |
| 1582 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1583 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1568 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1584 EXPECT_FALSE( | 1569 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension2_->id())); |
| 1585 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | |
| 1586 | 1570 |
| 1587 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1571 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1588 | 1572 |
| 1589 EXPECT_EQ(3, model_->item_count()); | 1573 EXPECT_EQ(3, model_->item_count()); |
| 1590 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1574 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1591 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1575 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1592 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1576 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1593 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1577 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1594 EXPECT_FALSE( | 1578 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension2_->id())); |
| 1595 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | |
| 1596 | 1579 |
| 1597 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1580 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1598 | 1581 |
| 1599 EXPECT_EQ(2, model_->item_count()); | 1582 EXPECT_EQ(2, model_->item_count()); |
| 1600 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1583 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1601 EXPECT_FALSE( | 1584 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1602 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1603 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1585 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1604 EXPECT_FALSE( | 1586 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension2_->id())); |
| 1605 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | |
| 1606 } | 1587 } |
| 1607 | 1588 |
| 1608 // Check that multiple locks of an application will be properly handled. | 1589 // Check that multiple locks of an application will be properly handled. |
| 1609 TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) { | 1590 TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) { |
| 1610 InitLauncherController(); | 1591 InitLauncherController(); |
| 1611 // Model should only contain the browser shortcut and app list items. | 1592 // Model should only contain the browser shortcut and app list items. |
| 1612 EXPECT_EQ(2, model_->item_count()); | 1593 EXPECT_EQ(2, model_->item_count()); |
| 1613 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1594 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1614 EXPECT_FALSE( | 1595 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1615 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1616 | 1596 |
| 1617 for (int i = 0; i < 2; i++) { | 1597 for (int i = 0; i < 2; i++) { |
| 1618 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1598 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1619 | 1599 |
| 1620 EXPECT_EQ(3, model_->item_count()); | 1600 EXPECT_EQ(3, model_->item_count()); |
| 1621 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1601 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1622 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1602 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1623 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher( | 1603 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1624 extension1_->id())); | |
| 1625 } | 1604 } |
| 1626 | 1605 |
| 1627 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1606 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1628 | 1607 |
| 1629 EXPECT_EQ(3, model_->item_count()); | 1608 EXPECT_EQ(3, model_->item_count()); |
| 1630 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1609 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1631 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1610 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1632 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1611 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1633 | 1612 |
| 1634 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1613 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1635 | 1614 |
| 1636 EXPECT_EQ(2, model_->item_count()); | 1615 EXPECT_EQ(2, model_->item_count()); |
| 1637 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1616 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1638 EXPECT_FALSE( | 1617 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1639 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1640 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | |
| 1641 EXPECT_FALSE( | |
| 1642 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1643 } | 1618 } |
| 1644 | 1619 |
| 1645 // Check that already pinned items are not effected by locks. | 1620 // Check that already pinned items are not effected by locks. |
| 1646 TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) { | 1621 TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) { |
| 1647 InitLauncherController(); | 1622 InitLauncherController(); |
| 1648 // Model should only contain the browser shortcut and app list items. | 1623 // Model should only contain the browser shortcut and app list items. |
| 1649 EXPECT_EQ(2, model_->item_count()); | 1624 EXPECT_EQ(2, model_->item_count()); |
| 1650 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1625 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1651 EXPECT_FALSE( | 1626 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1652 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1653 | 1627 |
| 1654 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 1655 launcher_controller_->PinAppWithID(extension1_->id()); | 1628 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1656 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 1657 | 1629 |
| 1658 EXPECT_EQ(3, model_->item_count()); | 1630 EXPECT_EQ(3, model_->item_count()); |
| 1659 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1631 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1660 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1632 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1661 EXPECT_FALSE( | 1633 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1662 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1663 | 1634 |
| 1664 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1635 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1665 | 1636 |
| 1666 EXPECT_EQ(3, model_->item_count()); | 1637 EXPECT_EQ(3, model_->item_count()); |
| 1667 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1638 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1668 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1639 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1669 EXPECT_FALSE( | 1640 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1670 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1671 | 1641 |
| 1672 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1642 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1673 | 1643 |
| 1674 EXPECT_EQ(3, model_->item_count()); | 1644 EXPECT_EQ(3, model_->item_count()); |
| 1675 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1645 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1676 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1646 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1677 EXPECT_FALSE( | 1647 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1678 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1679 | 1648 |
| 1680 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1649 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1681 | 1650 |
| 1682 EXPECT_EQ(2, model_->item_count()); | 1651 EXPECT_EQ(2, model_->item_count()); |
| 1652 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 1653 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); | |
| 1683 } | 1654 } |
| 1684 | 1655 |
| 1685 // Check that already pinned items which get locked stay after unpinning. | 1656 // Check that already pinned items which get locked stay after unpinning. |
| 1686 TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) { | 1657 TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) { |
| 1687 InitLauncherController(); | 1658 InitLauncherController(); |
| 1688 // Model should only contain the browser shortcut and app list items. | 1659 // Model should only contain the browser shortcut and app list items. |
| 1689 EXPECT_EQ(2, model_->item_count()); | 1660 EXPECT_EQ(2, model_->item_count()); |
| 1690 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1661 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1691 EXPECT_FALSE( | 1662 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1692 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1693 | 1663 |
| 1694 launcher_controller_->PinAppWithID(extension1_->id()); | 1664 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1695 | 1665 |
| 1696 EXPECT_EQ(3, model_->item_count()); | 1666 EXPECT_EQ(3, model_->item_count()); |
| 1697 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1667 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1698 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1668 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1699 EXPECT_FALSE( | 1669 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1700 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1701 | 1670 |
| 1702 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1671 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1703 | 1672 |
| 1704 EXPECT_EQ(3, model_->item_count()); | 1673 EXPECT_EQ(3, model_->item_count()); |
| 1705 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1674 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1706 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1675 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1707 EXPECT_FALSE( | 1676 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1708 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1709 | 1677 |
| 1710 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1678 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1711 | 1679 |
| 1712 EXPECT_EQ(3, model_->item_count()); | 1680 EXPECT_EQ(3, model_->item_count()); |
| 1713 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1681 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1714 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1682 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1715 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1683 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1716 | 1684 |
| 1717 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1685 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1718 | 1686 |
| 1719 EXPECT_EQ(2, model_->item_count()); | 1687 EXPECT_EQ(2, model_->item_count()); |
| 1688 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 1689 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); | |
| 1720 } | 1690 } |
| 1721 | 1691 |
| 1722 // Check that running applications wich are not pinned get properly restored | 1692 // Check that running applications wich are not pinned get properly restored |
| 1723 // upon user change. | 1693 // upon user change. |
| 1724 TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) { | 1694 TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) { |
| 1725 InitLauncherController(); | 1695 InitLauncherController(); |
| 1726 // Model should only contain the browser shortcut and app list items. | 1696 // Model should only contain the browser shortcut and app list items. |
| 1727 EXPECT_EQ(2, model_->item_count()); | 1697 EXPECT_EQ(2, model_->item_count()); |
| 1728 | 1698 |
| 1729 // Add a few running applications. | 1699 // Add a few running applications. |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2274 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); | 2244 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); |
| 2275 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); | 2245 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); |
| 2276 } | 2246 } |
| 2277 | 2247 |
| 2278 // Check that lock -> pin -> unlock -> unpin does properly transition. | 2248 // Check that lock -> pin -> unlock -> unpin does properly transition. |
| 2279 TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) { | 2249 TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) { |
| 2280 InitLauncherController(); | 2250 InitLauncherController(); |
| 2281 // Model should only contain the browser shortcut and app list items. | 2251 // Model should only contain the browser shortcut and app list items. |
| 2282 EXPECT_EQ(2, model_->item_count()); | 2252 EXPECT_EQ(2, model_->item_count()); |
| 2283 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2253 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2284 EXPECT_FALSE( | 2254 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2285 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 2286 | 2255 |
| 2287 launcher_controller_->LockV1AppWithID(extension1_->id()); | 2256 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 2288 | 2257 |
| 2289 EXPECT_EQ(3, model_->item_count()); | 2258 EXPECT_EQ(3, model_->item_count()); |
| 2290 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 2259 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 2291 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2260 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2292 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 2261 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2293 | 2262 |
| 2294 launcher_controller_->PinAppWithID(extension1_->id()); | 2263 launcher_controller_->PinAppWithID(extension1_->id()); |
| 2295 | 2264 |
| 2296 EXPECT_EQ(3, model_->item_count()); | 2265 EXPECT_EQ(3, model_->item_count()); |
| 2297 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 2266 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 2298 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2267 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2299 EXPECT_FALSE( | 2268 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2300 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 2301 | 2269 |
| 2302 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 2270 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 2303 | 2271 |
| 2304 EXPECT_EQ(3, model_->item_count()); | 2272 EXPECT_EQ(3, model_->item_count()); |
| 2305 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 2273 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 2306 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2274 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2307 EXPECT_FALSE( | 2275 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2308 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 2309 | 2276 |
| 2310 launcher_controller_->UnpinAppWithID(extension1_->id()); | 2277 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 2311 | 2278 |
| 2312 EXPECT_EQ(2, model_->item_count()); | 2279 EXPECT_EQ(2, model_->item_count()); |
| 2280 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 2281 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(extension1_->id())); | |
| 2313 } | 2282 } |
| 2314 | 2283 |
| 2315 // Check that a locked (windowed V1 application) will be properly converted | 2284 // Check that a locked (windowed V1 application) will be properly converted |
| 2316 // between locked and pinned when the order gets changed through a profile / | 2285 // between locked and pinned when the order gets changed through a profile / |
| 2317 // policy change. | 2286 // policy change. |
| 2318 TEST_F(ChromeLauncherControllerImplTest, | 2287 TEST_F(ChromeLauncherControllerImplTest, |
| 2319 RestoreDefaultAndLockedAppsResyncOrder) { | 2288 RestoreDefaultAndLockedAppsResyncOrder) { |
| 2320 InitLauncherController(); | 2289 InitLauncherController(); |
| 2321 | 2290 |
| 2322 syncer::SyncChangeList sync_list; | 2291 syncer::SyncChangeList sync_list; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2368 TEST_F(ChromeLauncherControllerImplTest, | 2337 TEST_F(ChromeLauncherControllerImplTest, |
| 2369 RestoreDefaultAndRunningV2AppsResyncOrder) { | 2338 RestoreDefaultAndRunningV2AppsResyncOrder) { |
| 2370 InitLauncherController(); | 2339 InitLauncherController(); |
| 2371 syncer::SyncChangeList sync_list0; | 2340 syncer::SyncChangeList sync_list0; |
| 2372 InsertAddPinChange(&sync_list0, 0, extension1_->id()); | 2341 InsertAddPinChange(&sync_list0, 0, extension1_->id()); |
| 2373 InsertAddPinChange(&sync_list0, 1, extension3_->id()); | 2342 InsertAddPinChange(&sync_list0, 1, extension3_->id()); |
| 2374 SendPinChanges(sync_list0, true); | 2343 SendPinChanges(sync_list0, true); |
| 2375 // The shelf layout has always one static item at the beginning (app List). | 2344 // The shelf layout has always one static item at the beginning (app List). |
| 2376 extension_service_->AddExtension(extension1_.get()); | 2345 extension_service_->AddExtension(extension1_.get()); |
| 2377 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 2346 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
| 2378 extension_service_->AddExtension(extension2_.get()); | 2347 extension_service_->AddExtension(extension_platform_app_.get()); |
| 2379 // No new app icon will be generated. | 2348 // No new app icon will be generated. |
| 2380 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 2349 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
| 2381 // Add the app as an unpinned but running V2 app. | 2350 // Add an unpinned but running V2 app. |
| 2382 CreateRunningV2App(extension2_->id()); | 2351 CreateRunningV2App(extension_platform_app_->id()); |
| 2383 EXPECT_EQ("AppList, Chrome, App1, *app2", GetPinnedAppStatus()); | 2352 EXPECT_EQ("AppList, Chrome, App1, *platform_app", GetPinnedAppStatus()); |
| 2384 extension_service_->AddExtension(extension3_.get()); | 2353 extension_service_->AddExtension(extension3_.get()); |
| 2385 EXPECT_EQ("AppList, Chrome, App1, App3, *app2", GetPinnedAppStatus()); | 2354 EXPECT_EQ("AppList, Chrome, App1, App3, *platform_app", GetPinnedAppStatus()); |
| 2386 | 2355 |
| 2387 // Now request to pin all items which should convert the locked item into a | 2356 // Now request to pin all items which should convert the locked item into a |
| 2388 // pinned item. | 2357 // pinned item. |
| 2389 syncer::SyncChangeList sync_list1; | 2358 syncer::SyncChangeList sync_list1; |
| 2390 InsertAddPinChange(&sync_list1, 0, extension3_->id()); | 2359 InsertAddPinChange(&sync_list1, 0, extension3_->id()); |
| 2391 InsertAddPinChange(&sync_list1, 1, extension2_->id()); | 2360 InsertAddPinChange(&sync_list1, 1, extension_platform_app_->id()); |
| 2392 InsertAddPinChange(&sync_list1, 2, extension1_->id()); | 2361 InsertAddPinChange(&sync_list1, 2, extension1_->id()); |
| 2393 SendPinChanges(sync_list1, true); | 2362 SendPinChanges(sync_list1, true); |
| 2394 EXPECT_EQ("AppList, Chrome, App3, App2, App1", GetPinnedAppStatus()); | 2363 EXPECT_EQ("AppList, Chrome, App3, *Platform_App, App1", GetPinnedAppStatus()); |
| 2395 | 2364 |
| 2396 // Going back to a status where there is no requirement for app 2 to be pinned | 2365 // Going back to a status where there is no requirement for the V2 app to be |
| 2397 // should convert it back to running V2 app. Since the position is determined | 2366 // pinned should convert it back to running V2 app. Since the position is |
| 2398 // by the |ShelfModel|'s weight system, it will be after last pinned item. | 2367 // determined by the |ShelfModel|'s weight system, it will be after last |
| 2368 // pinned item. | |
| 2399 syncer::SyncChangeList sync_list2; | 2369 syncer::SyncChangeList sync_list2; |
| 2400 InsertAddPinChange(&sync_list2, 0, extension3_->id()); | 2370 InsertAddPinChange(&sync_list2, 0, extension3_->id()); |
| 2401 InsertAddPinChange(&sync_list2, 1, extension1_->id()); | 2371 InsertAddPinChange(&sync_list2, 1, extension1_->id()); |
| 2402 SendPinChanges(sync_list2, true); | 2372 SendPinChanges(sync_list2, true); |
| 2403 EXPECT_EQ("AppList, Chrome, App3, App1, *app2", GetPinnedAppStatus()); | 2373 EXPECT_EQ("AppList, Chrome, App3, App1, *platform_app", GetPinnedAppStatus()); |
| 2404 | 2374 |
| 2405 // Removing an item should simply close it and everything should shift. | 2375 // Removing an item should simply close it and everything should shift. |
| 2406 syncer::SyncChangeList sync_list3; | 2376 syncer::SyncChangeList sync_list3; |
| 2407 InsertAddPinChange(&sync_list3, 0, extension3_->id()); | 2377 InsertAddPinChange(&sync_list3, 0, extension3_->id()); |
| 2408 SendPinChanges(sync_list3, true); | 2378 SendPinChanges(sync_list3, true); |
| 2409 EXPECT_EQ("AppList, Chrome, App3, *app2", GetPinnedAppStatus()); | 2379 EXPECT_EQ("AppList, Chrome, App3, *platform_app", GetPinnedAppStatus()); |
| 2410 } | 2380 } |
| 2411 | 2381 |
| 2412 // Each user has a different set of applications pinned. Check that when | 2382 // Each user has a different set of applications pinned. Check that when |
| 2413 // switching between the two users, the state gets properly set. | 2383 // switching between the two users, the state gets properly set. |
| 2414 TEST_F(ChromeLauncherControllerImplTest, UserSwitchIconRestore) { | 2384 TEST_F(ChromeLauncherControllerImplTest, UserSwitchIconRestore) { |
| 2415 syncer::SyncChangeList user_a; | 2385 syncer::SyncChangeList user_a; |
| 2416 syncer::SyncChangeList user_b; | 2386 syncer::SyncChangeList user_b; |
| 2417 | 2387 |
| 2418 SetUpMultiUserScenario(&user_a, &user_b); | 2388 SetUpMultiUserScenario(&user_a, &user_b); |
| 2419 | 2389 |
| 2420 // Show user 1. | 2390 // Show user 1. |
| 2421 SendPinChanges(user_a, true); | 2391 SendPinChanges(user_a, true); |
| 2422 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", | 2392 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", |
| 2423 GetPinnedAppStatus()); | 2393 GetPinnedAppStatus()); |
| 2424 | 2394 |
| 2425 // Show user 2. | 2395 // Show user 2. |
| 2426 SendPinChanges(user_b, true); | 2396 SendPinChanges(user_b, true); |
| 2427 EXPECT_EQ("AppList, App7, App8, Chrome", GetPinnedAppStatus()); | 2397 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus()); |
| 2428 | 2398 |
| 2429 // Switch back to 1. | 2399 // Switch back to 1. |
| 2430 SendPinChanges(user_a, true); | 2400 SendPinChanges(user_a, true); |
| 2431 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", | 2401 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", |
| 2432 GetPinnedAppStatus()); | 2402 GetPinnedAppStatus()); |
| 2433 | 2403 |
| 2434 // Switch back to 2. | 2404 // Switch back to 2. |
| 2435 SendPinChanges(user_b, true); | 2405 SendPinChanges(user_b, true); |
| 2436 EXPECT_EQ("AppList, App7, App8, Chrome", GetPinnedAppStatus()); | 2406 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus()); |
| 2437 } | 2407 } |
| 2438 | 2408 |
| 2439 // Each user has a different set of applications pinned, and one user has an | 2409 // Each user has a different set of applications pinned, and one user has an |
| 2440 // application running. Check that when switching between the two users, the | 2410 // application running. Check that when switching between the two users, the |
| 2441 // state gets properly set. | 2411 // state gets properly set. |
| 2442 TEST_F(ChromeLauncherControllerImplTest, | 2412 TEST_F(ChromeLauncherControllerImplTest, |
| 2443 UserSwitchIconRestoreWithRunningV2App) { | 2413 UserSwitchIconRestoreWithRunningV2App) { |
| 2444 syncer::SyncChangeList user_a; | 2414 syncer::SyncChangeList user_a; |
| 2445 syncer::SyncChangeList user_b; | 2415 syncer::SyncChangeList user_b; |
| 2446 | 2416 |
| 2447 SetUpMultiUserScenario(&user_a, &user_b); | 2417 SetUpMultiUserScenario(&user_a, &user_b); |
| 2448 | 2418 |
| 2449 // Run App1 and assume that it is a V2 app. | 2419 // Run the platform (V2) app. |
| 2450 CreateRunningV2App(extension1_->id()); | 2420 CreateRunningV2App(extension_platform_app_->id()); |
| 2451 | 2421 |
| 2452 // Show user 1. | 2422 // Show user 1. |
| 2453 SendPinChanges(user_a, true); | 2423 SendPinChanges(user_a, true); |
| 2454 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", | 2424 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", |
| 2455 GetPinnedAppStatus()); | 2425 GetPinnedAppStatus()); |
| 2456 | 2426 |
| 2457 // Show user 2. | 2427 // Show user 2. |
| 2458 SendPinChanges(user_b, true); | 2428 SendPinChanges(user_b, true); |
| 2459 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus()); | 2429 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", |
| 2430 GetPinnedAppStatus()); | |
| 2460 | 2431 |
| 2461 // Switch back to 1. | 2432 // Switch back to 1. |
| 2462 SendPinChanges(user_a, true); | 2433 SendPinChanges(user_a, true); |
| 2463 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", | 2434 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", |
| 2464 GetPinnedAppStatus()); | 2435 GetPinnedAppStatus()); |
| 2465 | 2436 |
| 2466 // Switch back to 2. | 2437 // Switch back to 2. |
| 2467 SendPinChanges(user_b, true); | 2438 SendPinChanges(user_b, true); |
| 2468 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus()); | 2439 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", |
| 2440 GetPinnedAppStatus()); | |
| 2469 } | 2441 } |
| 2470 | 2442 |
| 2471 // Each user has a different set of applications pinned, and one user has an | 2443 // Each user has a different set of applications pinned, and one user has an |
| 2472 // application running. The chrome icon is not the last item in the list. | 2444 // application running. The chrome icon is not the last item in the list. |
| 2473 // Check that when switching between the two users, the state gets properly set. | 2445 // Check that when switching between the two users, the state gets properly set. |
| 2474 // There was once a bug associated with this. | 2446 // There was once a bug associated with this. |
| 2475 TEST_F(ChromeLauncherControllerImplTest, | 2447 TEST_F(ChromeLauncherControllerImplTest, |
| 2476 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) { | 2448 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) { |
| 2477 syncer::SyncChangeList user_a; | 2449 syncer::SyncChangeList user_a; |
| 2478 syncer::SyncChangeList user_b; | 2450 syncer::SyncChangeList user_b; |
| 2479 SetUpMultiUserScenario(&user_a, &user_b); | 2451 SetUpMultiUserScenario(&user_a, &user_b); |
| 2480 | 2452 |
| 2481 // Run App1 and assume that it is a V2 app. | 2453 // Run the platform (V2) app. |
| 2482 CreateRunningV2App(extension1_->id()); | 2454 CreateRunningV2App(extension_platform_app_->id()); |
| 2483 | 2455 |
| 2484 // Show user 1. | 2456 // Show user 1. |
| 2485 SendPinChanges(user_a, true); | 2457 SendPinChanges(user_a, true); |
| 2486 SetShelfChromeIconIndex(5); | 2458 SetShelfChromeIconIndex(5); |
| 2487 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, Chrome, App6", | 2459 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5", |
| 2488 GetPinnedAppStatus()); | 2460 GetPinnedAppStatus()); |
| 2489 | 2461 |
| 2490 // Show user 2. | 2462 // Show user 2. |
| 2491 SendPinChanges(user_b, true); | 2463 SendPinChanges(user_b, true); |
| 2492 SetShelfChromeIconIndex(4); | 2464 SetShelfChromeIconIndex(4); |
| 2493 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus()); | 2465 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", |
| 2466 GetPinnedAppStatus()); | |
| 2494 | 2467 |
| 2495 // Switch back to 1. | 2468 // Switch back to 1. |
| 2496 SendPinChanges(user_a, true); | 2469 SendPinChanges(user_a, true); |
| 2497 SetShelfChromeIconIndex(5); | 2470 SetShelfChromeIconIndex(5); |
| 2498 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, Chrome, App6", | 2471 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5", |
| 2499 GetPinnedAppStatus()); | 2472 GetPinnedAppStatus()); |
| 2500 } | 2473 } |
| 2501 | 2474 |
| 2502 TEST_F(ChromeLauncherControllerImplTest, Policy) { | 2475 TEST_F(ChromeLauncherControllerImplTest, Policy) { |
| 2503 extension_service_->AddExtension(extension1_.get()); | 2476 extension_service_->AddExtension(extension1_.get()); |
| 2504 extension_service_->AddExtension(extension3_.get()); | 2477 extension_service_->AddExtension(extension3_.get()); |
| 2505 | 2478 |
| 2506 InitLauncherController(); | 2479 InitLauncherController(); |
| 2507 | 2480 |
| 2508 syncer::SyncChangeList sync_list; | 2481 syncer::SyncChangeList sync_list; |
| (...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4030 | 4003 |
| 4031 // Pinned state should not change. | 4004 // Pinned state should not change. |
| 4032 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4005 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4033 launcher_controller_->UnpinAppWithID(extension2_->id()); | 4006 launcher_controller_->UnpinAppWithID(extension2_->id()); |
| 4034 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 4007 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
| 4035 | 4008 |
| 4036 // Resume syncing and sync information overrides local copy. | 4009 // Resume syncing and sync information overrides local copy. |
| 4037 StartAppSyncService(copy_sync_list); | 4010 StartAppSyncService(copy_sync_list); |
| 4038 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4011 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4039 } | 4012 } |
| OLD | NEW |