| 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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "ash/common/ash_switches.h" | 17 #include "ash/common/ash_switches.h" |
| 18 #include "ash/common/shelf/shelf_constants.h" |
| 18 #include "ash/common/shelf/shelf_controller.h" | 19 #include "ash/common/shelf/shelf_controller.h" |
| 20 #include "ash/common/shelf/shelf_item_types.h" |
| 19 #include "ash/common/shelf/shelf_model.h" | 21 #include "ash/common/shelf/shelf_model.h" |
| 20 #include "ash/common/shelf/shelf_model_observer.h" | 22 #include "ash/common/shelf/shelf_model_observer.h" |
| 21 #include "ash/common/test/test_session_state_delegate.h" | 23 #include "ash/common/test/test_session_state_delegate.h" |
| 22 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 24 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 23 #include "ash/common/wm_shell.h" | 25 #include "ash/common/wm_shell.h" |
| 24 #include "ash/display/screen_orientation_controller_chromeos.h" | 26 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 25 #include "ash/shell.h" | 27 #include "ash/shell.h" |
| 26 #include "ash/test/ash_test_helper.h" | 28 #include "ash/test/ash_test_helper.h" |
| 27 #include "ash/test/test_shell_delegate.h" | 29 #include "ash/test/test_shell_delegate.h" |
| 28 #include "ash/wm/window_util.h" | 30 #include "ash/wm/window_util.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 model_observer_.reset(new TestShelfModelObserver); | 320 model_observer_.reset(new TestShelfModelObserver); |
| 319 model_->AddObserver(model_observer_.get()); | 321 model_->AddObserver(model_observer_.get()); |
| 320 | 322 |
| 321 base::DictionaryValue manifest; | 323 base::DictionaryValue manifest; |
| 322 manifest.SetString(extensions::manifest_keys::kName, | 324 manifest.SetString(extensions::manifest_keys::kName, |
| 323 "launcher controller test extension"); | 325 "launcher controller test extension"); |
| 324 manifest.SetString(extensions::manifest_keys::kVersion, "1"); | 326 manifest.SetString(extensions::manifest_keys::kVersion, "1"); |
| 325 manifest.SetString(extensions::manifest_keys::kDescription, | 327 manifest.SetString(extensions::manifest_keys::kDescription, |
| 326 "for testing pinned apps"); | 328 "for testing pinned apps"); |
| 327 | 329 |
| 330 base::DictionaryValue manifest_platform_app; |
| 331 manifest_platform_app.SetString(extensions::manifest_keys::kName, |
| 332 "launcher controller test platform app"); |
| 333 manifest_platform_app.SetString(extensions::manifest_keys::kVersion, "1"); |
| 334 manifest_platform_app.SetString(extensions::manifest_keys::kDescription, |
| 335 "for testing pinned platform apps"); |
| 336 manifest_platform_app.SetString(extensions::manifest_keys::kApp, "true"); |
| 337 manifest_platform_app.Set(extensions::manifest_keys::kPlatformAppBackground, |
| 338 new base::DictionaryValue()); |
| 339 base::ListValue* scripts = new base::ListValue(); |
| 340 scripts->AppendString("main.js"); |
| 341 manifest_platform_app.Set( |
| 342 extensions::manifest_keys::kPlatformAppBackgroundScripts, scripts); |
| 343 |
| 328 extensions::TestExtensionSystem* extension_system( | 344 extensions::TestExtensionSystem* extension_system( |
| 329 static_cast<extensions::TestExtensionSystem*>( | 345 static_cast<extensions::TestExtensionSystem*>( |
| 330 extensions::ExtensionSystem::Get(profile()))); | 346 extensions::ExtensionSystem::Get(profile()))); |
| 331 extension_service_ = extension_system->CreateExtensionService( | 347 extension_service_ = extension_system->CreateExtensionService( |
| 332 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); | 348 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 333 extension_service_->Init(); | 349 extension_service_->Init(); |
| 334 | 350 |
| 335 if (auto_start_arc_test_) | 351 if (auto_start_arc_test_) |
| 336 arc_test_.SetUp(profile()); | 352 arc_test_.SetUp(profile()); |
| 337 | 353 |
| 338 // Wait until |extension_system| is signaled as started. | 354 // Wait until |extension_system| is signaled as started. |
| 339 base::RunLoop run_loop; | 355 base::RunLoop run_loop; |
| 340 extension_system->ready().Post(FROM_HERE, run_loop.QuitClosure()); | 356 extension_system->ready().Post(FROM_HERE, run_loop.QuitClosure()); |
| 341 run_loop.Run(); | 357 run_loop.Run(); |
| 342 | 358 |
| 343 app_service_ = | 359 app_service_ = |
| 344 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 360 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
| 345 StartAppSyncService(syncer::SyncDataList()); | 361 StartAppSyncService(syncer::SyncDataList()); |
| 346 | 362 |
| 347 std::string error; | 363 std::string error; |
| 348 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 364 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 349 manifest, | 365 manifest, Extension::NO_FLAGS, |
| 350 Extension::NO_FLAGS, | 366 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", &error); |
| 351 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | |
| 352 &error); | |
| 353 extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 367 extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 354 manifest, | 368 manifest, Extension::NO_FLAGS, |
| 355 Extension::NO_FLAGS, | 369 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", &error); |
| 356 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", | |
| 357 &error); | |
| 358 // Fake gmail extension. | 370 // Fake gmail extension. |
| 359 base::DictionaryValue manifest_gmail; | 371 base::DictionaryValue manifest_gmail; |
| 360 manifest_gmail.SetString(extensions::manifest_keys::kName, | 372 manifest_gmail.SetString(extensions::manifest_keys::kName, |
| 361 "Gmail launcher controller test extension"); | 373 "Gmail launcher controller test extension"); |
| 362 manifest_gmail.SetString(extensions::manifest_keys::kVersion, "1"); | 374 manifest_gmail.SetString(extensions::manifest_keys::kVersion, "1"); |
| 363 manifest_gmail.SetString(extensions::manifest_keys::kDescription, | 375 manifest_gmail.SetString(extensions::manifest_keys::kDescription, |
| 364 "for testing pinned Gmail"); | 376 "for testing pinned Gmail"); |
| 365 manifest_gmail.SetString(extensions::manifest_keys::kLaunchWebURL, | 377 manifest_gmail.SetString(extensions::manifest_keys::kLaunchWebURL, |
| 366 kGmailLaunchURL); | 378 kGmailLaunchURL); |
| 367 base::ListValue* list = new base::ListValue(); | 379 base::ListValue* list = new base::ListValue(); |
| 368 list->AppendString("*://mail.google.com/mail/ca"); | 380 list->AppendString("*://mail.google.com/mail/ca"); |
| 369 manifest_gmail.Set(extensions::manifest_keys::kWebURLs, list); | 381 manifest_gmail.Set(extensions::manifest_keys::kWebURLs, list); |
| 370 | 382 |
| 371 extension3_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 383 extension3_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 372 manifest_gmail, | 384 manifest_gmail, Extension::NO_FLAGS, |
| 373 Extension::NO_FLAGS, | 385 extension_misc::kGmailAppId, &error); |
| 374 extension_misc::kGmailAppId, | |
| 375 &error); | |
| 376 | 386 |
| 377 // Fake google docs extension. | 387 // Fake google docs extension. |
| 378 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 388 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 379 manifest, | 389 manifest, Extension::NO_FLAGS, |
| 380 Extension::NO_FLAGS, | 390 extension_misc::kGoogleDocAppId, &error); |
| 381 extension_misc::kGoogleDocAppId, | |
| 382 &error); | |
| 383 extension5_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 391 extension5_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 384 manifest, | 392 manifest, Extension::NO_FLAGS, |
| 385 Extension::NO_FLAGS, | 393 "cccccccccccccccccccccccccccccccc", &error); |
| 386 "cccccccccccccccccccccccccccccccc", | |
| 387 &error); | |
| 388 extension6_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 394 extension6_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 389 manifest, | 395 manifest, Extension::NO_FLAGS, |
| 390 Extension::NO_FLAGS, | 396 "dddddddddddddddddddddddddddddddd", &error); |
| 391 "dddddddddddddddddddddddddddddddd", | |
| 392 &error); | |
| 393 extension7_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 397 extension7_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 394 manifest, | 398 manifest, Extension::NO_FLAGS, |
| 395 Extension::NO_FLAGS, | 399 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", &error); |
| 396 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", | |
| 397 &error); | |
| 398 extension8_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 400 extension8_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 399 manifest, | 401 manifest, Extension::NO_FLAGS, |
| 400 Extension::NO_FLAGS, | 402 "ffffffffffffffffffffffffffffffff", &error); |
| 401 "ffffffffffffffffffffffffffffffff", | 403 extension_platform_app_ = Extension::Create( |
| 402 &error); | 404 base::FilePath(), Manifest::UNPACKED, manifest_platform_app, |
| 405 Extension::NO_FLAGS, "gggggggggggggggggggggggggggggggg", &error); |
| 403 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 406 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 404 manifest, Extension::NO_FLAGS, | 407 manifest, Extension::NO_FLAGS, |
| 405 ArcSupportHost::kHostAppId, &error); | 408 ArcSupportHost::kHostAppId, &error); |
| 406 } | 409 } |
| 407 | 410 |
| 408 // Creates a running V2 app (not pinned) of type |app_id|. | 411 // Creates a running platform V2 app (not pinned) of type |app_id|. |
| 409 virtual void CreateRunningV2App(const std::string& app_id) { | 412 virtual void CreateRunningV2App(const std::string& app_id) { |
| 410 DCHECK(!test_controller_); | 413 DCHECK(!test_controller_); |
| 411 ash::ShelfID id = | 414 ash::ShelfID id = |
| 412 launcher_controller_->CreateAppShortcutLauncherItemWithType( | 415 launcher_controller_->CreateAppShortcutLauncherItemWithType( |
| 413 ash::launcher::AppLauncherId(app_id), model_->item_count(), | 416 ash::launcher::AppLauncherId(app_id), model_->item_count(), |
| 414 ash::TYPE_PLATFORM_APP); | 417 ash::TYPE_APP); |
| 415 DCHECK(id); | 418 DCHECK(id); |
| 416 // Change the created launcher controller into a V2 app controller. | 419 // Change the created launcher controller into a V2 app controller. |
| 417 test_controller_ = new TestV2AppLauncherItemController(app_id, | 420 test_controller_ = new TestV2AppLauncherItemController(app_id, |
| 418 launcher_controller_.get()); | 421 launcher_controller_.get()); |
| 419 launcher_controller_->SetItemController(id, test_controller_); | 422 launcher_controller_->SetItemController(id, test_controller_); |
| 423 DCHECK(launcher_controller_->IsPlatformApp(id)); |
| 420 } | 424 } |
| 421 | 425 |
| 422 // Sets the stage for a multi user test. | 426 // Sets the stage for a multi user test. |
| 423 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, | 427 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, |
| 424 syncer::SyncChangeList* user_b) { | 428 syncer::SyncChangeList* user_b) { |
| 425 InitLauncherController(); | 429 InitLauncherController(); |
| 426 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 430 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 427 | 431 |
| 428 // Set an empty pinned pref to begin with. | 432 // Set an empty pinned pref to begin with. |
| 429 syncer::SyncChangeList sync_list; | 433 syncer::SyncChangeList sync_list; |
| 430 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); | 434 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); |
| 431 SendPinChanges(sync_list, true); | 435 SendPinChanges(sync_list, true); |
| 432 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 436 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 433 | 437 |
| 434 // Assume all applications have been added already. | 438 // Assume all applications have been added already. |
| 435 extension_service_->AddExtension(extension1_.get()); | 439 extension_service_->AddExtension(extension1_.get()); |
| 436 extension_service_->AddExtension(extension2_.get()); | 440 extension_service_->AddExtension(extension2_.get()); |
| 437 extension_service_->AddExtension(extension3_.get()); | 441 extension_service_->AddExtension(extension3_.get()); |
| 438 extension_service_->AddExtension(extension4_.get()); | 442 extension_service_->AddExtension(extension4_.get()); |
| 439 extension_service_->AddExtension(extension5_.get()); | 443 extension_service_->AddExtension(extension5_.get()); |
| 440 extension_service_->AddExtension(extension6_.get()); | 444 extension_service_->AddExtension(extension6_.get()); |
| 441 extension_service_->AddExtension(extension7_.get()); | 445 extension_service_->AddExtension(extension7_.get()); |
| 442 extension_service_->AddExtension(extension8_.get()); | 446 extension_service_->AddExtension(extension8_.get()); |
| 447 extension_service_->AddExtension(extension_platform_app_.get()); |
| 443 // There should be nothing in the list by now. | 448 // There should be nothing in the list by now. |
| 444 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 449 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
| 445 | 450 |
| 446 // Set user a preferences. | 451 // Set user a preferences. |
| 447 InsertAddPinChange(user_a, 0, extension1_->id()); | 452 InsertAddPinChange(user_a, 0, extension1_->id()); |
| 448 InsertAddPinChange(user_a, 1, extension2_->id()); | 453 InsertAddPinChange(user_a, 1, extension2_->id()); |
| 449 InsertAddPinChange(user_a, 2, extension3_->id()); | 454 InsertAddPinChange(user_a, 2, extension3_->id()); |
| 450 InsertAddPinChange(user_a, 3, extension4_->id()); | 455 InsertAddPinChange(user_a, 3, extension_platform_app_->id()); |
| 451 InsertAddPinChange(user_a, 4, extension5_->id()); | 456 InsertAddPinChange(user_a, 4, extension4_->id()); |
| 452 InsertAddPinChange(user_a, 5, extension6_->id()); | 457 InsertAddPinChange(user_a, 5, extension5_->id()); |
| 453 InsertAddPinChange(user_a, 6, extension_misc::kChromeAppId); | 458 InsertAddPinChange(user_a, 6, extension_misc::kChromeAppId); |
| 454 | 459 |
| 455 // Set user b preferences. | 460 // Set user b preferences. |
| 456 InsertAddPinChange(user_b, 0, extension7_->id()); | 461 InsertAddPinChange(user_b, 0, extension6_->id()); |
| 457 InsertAddPinChange(user_b, 1, extension8_->id()); | 462 InsertAddPinChange(user_b, 1, extension7_->id()); |
| 458 InsertAddPinChange(user_b, 2, extension_misc::kChromeAppId); | 463 InsertAddPinChange(user_b, 2, extension8_->id()); |
| 464 InsertAddPinChange(user_b, 3, extension_misc::kChromeAppId); |
| 459 } | 465 } |
| 460 | 466 |
| 461 void TearDown() override { | 467 void TearDown() override { |
| 462 arc_test_.TearDown(); | 468 arc_test_.TearDown(); |
| 463 model_->RemoveObserver(model_observer_.get()); | 469 model_->RemoveObserver(model_observer_.get()); |
| 464 model_observer_.reset(); | 470 model_observer_.reset(); |
| 465 launcher_controller_.reset(); | 471 launcher_controller_.reset(); |
| 466 BrowserWithTestWindowTest::TearDown(); | 472 BrowserWithTestWindowTest::TearDown(); |
| 467 } | 473 } |
| 468 | 474 |
| (...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. | 682 // 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 | 683 // 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 | 684 // pinned V1 app will start with a small letter and each running but not |
| 679 // pinned V2 app will start with a '*' + small letter. | 685 // pinned V2 app will start with a '*' + small letter. |
| 680 std::string GetPinnedAppStatus() { | 686 std::string GetPinnedAppStatus() { |
| 681 std::string result; | 687 std::string result; |
| 682 for (int i = 0; i < model_->item_count(); i++) { | 688 for (int i = 0; i < model_->item_count(); i++) { |
| 683 if (!result.empty()) | 689 if (!result.empty()) |
| 684 result.append(", "); | 690 result.append(", "); |
| 685 switch (model_->items()[i].type) { | 691 switch (model_->items()[i].type) { |
| 686 case ash::TYPE_PLATFORM_APP: | 692 case ash::TYPE_APP: { |
| 687 result += "*"; | 693 if (launcher_controller_->IsPlatformApp(model_->items()[i].id)) |
| 688 // FALLTHROUGH | 694 result += "*"; |
| 689 case ash::TYPE_WINDOWED_APP: { | |
| 690 const std::string& app = | 695 const std::string& app = |
| 691 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); | 696 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); |
| 692 if (app == extension1_->id()) { | 697 EXPECT_FALSE(launcher_controller_->IsAppPinned(app)); |
| 693 result += "app1"; | 698 if (app == extension1_->id()) { |
| 694 EXPECT_FALSE( | 699 result += "app1"; |
| 695 launcher_controller_->IsAppPinned(extension1_->id())); | 700 } else if (app == extension2_->id()) { |
| 696 } else if (app == extension2_->id()) { | 701 result += "app2"; |
| 697 result += "app2"; | 702 } else if (app == extension3_->id()) { |
| 698 EXPECT_FALSE( | 703 result += "app3"; |
| 699 launcher_controller_->IsAppPinned(extension2_->id())); | 704 } else if (app == extension4_->id()) { |
| 700 } else if (app == extension3_->id()) { | 705 result += "app4"; |
| 701 result += "app3"; | 706 } else if (app == extension5_->id()) { |
| 702 EXPECT_FALSE( | 707 result += "app5"; |
| 703 launcher_controller_->IsAppPinned(extension3_->id())); | 708 } else if (app == extension6_->id()) { |
| 704 } else if (app == extension4_->id()) { | 709 result += "app6"; |
| 705 result += "app4"; | 710 } else if (app == extension7_->id()) { |
| 706 EXPECT_FALSE( | 711 result += "app7"; |
| 707 launcher_controller_->IsAppPinned(extension4_->id())); | 712 } else if (app == extension8_->id()) { |
| 708 } else if (app == extension5_->id()) { | 713 result += "app8"; |
| 709 result += "app5"; | 714 } else if (app == extension_platform_app_->id()) { |
| 710 EXPECT_FALSE( | 715 result += "platform_app"; |
| 711 launcher_controller_->IsAppPinned(extension5_->id())); | 716 } else { |
| 712 } else if (app == extension6_->id()) { | 717 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 } | 718 } |
| 719 break; |
| 720 } |
| 729 case ash::TYPE_APP_SHORTCUT: { | 721 case ash::TYPE_APP_SHORTCUT: { |
| 722 if (launcher_controller_->IsPlatformApp(model_->items()[i].id)) |
| 723 result += "*"; |
| 730 const std::string& app = | 724 const std::string& app = |
| 731 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); | 725 launcher_controller_->GetAppIDForShelfID(model_->items()[i].id); |
| 732 if (app == extension1_->id()) { | 726 EXPECT_TRUE(launcher_controller_->IsAppPinned(app)); |
| 733 result += "App1"; | 727 if (app == extension1_->id()) { |
| 734 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 728 result += "App1"; |
| 735 } else if (app == extension2_->id()) { | 729 } else if (app == extension2_->id()) { |
| 736 result += "App2"; | 730 result += "App2"; |
| 737 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 731 } else if (app == extension3_->id()) { |
| 738 } else if (app == extension3_->id()) { | 732 result += "App3"; |
| 739 result += "App3"; | 733 } else if (app == extension4_->id()) { |
| 740 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 734 result += "App4"; |
| 741 } else if (app == extension4_->id()) { | 735 } else if (app == extension5_->id()) { |
| 742 result += "App4"; | 736 result += "App5"; |
| 743 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); | 737 } else if (app == extension6_->id()) { |
| 744 } else if (app == extension5_->id()) { | 738 result += "App6"; |
| 745 result += "App5"; | 739 } else if (app == extension7_->id()) { |
| 746 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension5_->id())); | 740 result += "App7"; |
| 747 } else if (app == extension6_->id()) { | 741 } else if (app == extension8_->id()) { |
| 748 result += "App6"; | 742 result += "App8"; |
| 749 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension6_->id())); | 743 } else if (app == extension_platform_app_->id()) { |
| 750 } else if (app == extension7_->id()) { | 744 result += "Platform_App"; |
| 751 result += "App7"; | 745 } else if (app == arc_support_host_->id()) { |
| 752 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension7_->id())); | 746 result += "Play Store"; |
| 753 } else if (app == extension8_->id()) { | 747 } else { |
| 754 result += "App8"; | 748 bool arc_app_found = false; |
| 755 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension8_->id())); | 749 for (const auto& arc_app : arc_test_.fake_apps()) { |
| 756 } else if (app == arc_support_host_->id()) { | 750 if (app == ArcAppTest::GetAppId(arc_app)) { |
| 757 result += "Play Store"; | 751 result += arc_app.name; |
| 758 EXPECT_TRUE( | 752 arc_app_found = true; |
| 759 launcher_controller_->IsAppPinned(arc_support_host_->id())); | 753 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 } | 754 } |
| 769 if (!arc_app_found) | |
| 770 result += "unknown"; | |
| 771 } | 755 } |
| 772 break; | 756 if (!arc_app_found) |
| 757 result += "unknown"; |
| 773 } | 758 } |
| 759 break; |
| 760 } |
| 774 case ash::TYPE_BROWSER_SHORTCUT: | 761 case ash::TYPE_BROWSER_SHORTCUT: |
| 775 result += "Chrome"; | 762 result += "Chrome"; |
| 776 break; | 763 break; |
| 777 case ash::TYPE_APP_LIST: | 764 case ash::TYPE_APP_LIST: |
| 778 result += "AppList"; | 765 result += "AppList"; |
| 779 break; | 766 break; |
| 780 default: | 767 default: |
| 781 result += "Unknown"; | 768 result += "Unknown"; |
| 782 break; | 769 break; |
| 783 } | 770 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 877 |
| 891 // Needed for extension service & friends to work. | 878 // Needed for extension service & friends to work. |
| 892 scoped_refptr<Extension> extension1_; | 879 scoped_refptr<Extension> extension1_; |
| 893 scoped_refptr<Extension> extension2_; | 880 scoped_refptr<Extension> extension2_; |
| 894 scoped_refptr<Extension> extension3_; | 881 scoped_refptr<Extension> extension3_; |
| 895 scoped_refptr<Extension> extension4_; | 882 scoped_refptr<Extension> extension4_; |
| 896 scoped_refptr<Extension> extension5_; | 883 scoped_refptr<Extension> extension5_; |
| 897 scoped_refptr<Extension> extension6_; | 884 scoped_refptr<Extension> extension6_; |
| 898 scoped_refptr<Extension> extension7_; | 885 scoped_refptr<Extension> extension7_; |
| 899 scoped_refptr<Extension> extension8_; | 886 scoped_refptr<Extension> extension8_; |
| 887 scoped_refptr<Extension> extension_platform_app_; |
| 900 scoped_refptr<Extension> arc_support_host_; | 888 scoped_refptr<Extension> arc_support_host_; |
| 901 | 889 |
| 902 ArcAppTest arc_test_; | 890 ArcAppTest arc_test_; |
| 903 bool auto_start_arc_test_ = false; | 891 bool auto_start_arc_test_ = false; |
| 904 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; | 892 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_; |
| 905 std::unique_ptr<TestShelfModelObserver> model_observer_; | 893 std::unique_ptr<TestShelfModelObserver> model_observer_; |
| 906 ash::ShelfModel* model_ = nullptr; | 894 ash::ShelfModel* model_ = nullptr; |
| 907 std::unique_ptr<TestingProfileManager> profile_manager_; | 895 std::unique_ptr<TestingProfileManager> profile_manager_; |
| 908 | 896 |
| 909 // |item_delegate_manager_| owns |test_controller_|. | 897 // |item_delegate_manager_| owns |test_controller_|. |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 UnloadedExtensionInfo::REASON_UPDATE); | 1559 UnloadedExtensionInfo::REASON_UPDATE); |
| 1572 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); | 1560 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); |
| 1573 } | 1561 } |
| 1574 | 1562 |
| 1575 // Check that simple locking of an application will 'create' a launcher item. | 1563 // Check that simple locking of an application will 'create' a launcher item. |
| 1576 TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) { | 1564 TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) { |
| 1577 InitLauncherController(); | 1565 InitLauncherController(); |
| 1578 // Model should only contain the browser shortcut and app list items. | 1566 // Model should only contain the browser shortcut and app list items. |
| 1579 EXPECT_EQ(2, model_->item_count()); | 1567 EXPECT_EQ(2, model_->item_count()); |
| 1580 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1568 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1581 EXPECT_FALSE( | 1569 EXPECT_EQ(ash::kInvalidShelfID, |
| 1582 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1570 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1583 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1571 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1584 EXPECT_FALSE( | 1572 EXPECT_EQ(ash::kInvalidShelfID, |
| 1585 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 1573 launcher_controller_->GetShelfIDForAppID(extension2_->id())); |
| 1586 | 1574 |
| 1587 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1575 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1588 | 1576 |
| 1589 EXPECT_EQ(3, model_->item_count()); | 1577 EXPECT_EQ(3, model_->item_count()); |
| 1590 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1578 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1591 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1579 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1592 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1580 EXPECT_NE(ash::kInvalidShelfID, |
| 1581 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1593 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1582 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1594 EXPECT_FALSE( | 1583 EXPECT_EQ(ash::kInvalidShelfID, |
| 1595 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 1584 launcher_controller_->GetShelfIDForAppID(extension2_->id())); |
| 1596 | 1585 |
| 1597 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1586 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1598 | 1587 |
| 1599 EXPECT_EQ(2, model_->item_count()); | 1588 EXPECT_EQ(2, model_->item_count()); |
| 1600 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1589 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1601 EXPECT_FALSE( | 1590 EXPECT_EQ(ash::kInvalidShelfID, |
| 1602 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1591 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1603 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1592 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1604 EXPECT_FALSE( | 1593 EXPECT_EQ(ash::kInvalidShelfID, |
| 1605 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 1594 launcher_controller_->GetShelfIDForAppID(extension2_->id())); |
| 1606 } | 1595 } |
| 1607 | 1596 |
| 1608 // Check that multiple locks of an application will be properly handled. | 1597 // Check that multiple locks of an application will be properly handled. |
| 1609 TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) { | 1598 TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) { |
| 1610 InitLauncherController(); | 1599 InitLauncherController(); |
| 1611 // Model should only contain the browser shortcut and app list items. | 1600 // Model should only contain the browser shortcut and app list items. |
| 1612 EXPECT_EQ(2, model_->item_count()); | 1601 EXPECT_EQ(2, model_->item_count()); |
| 1613 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1602 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1614 EXPECT_FALSE( | 1603 EXPECT_EQ(ash::kInvalidShelfID, |
| 1615 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1604 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1616 | 1605 |
| 1617 for (int i = 0; i < 2; i++) { | 1606 for (int i = 0; i < 2; i++) { |
| 1618 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1607 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1619 | 1608 |
| 1620 EXPECT_EQ(3, model_->item_count()); | 1609 EXPECT_EQ(3, model_->item_count()); |
| 1621 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1610 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1622 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1611 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1623 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher( | 1612 EXPECT_NE(ash::kInvalidShelfID, |
| 1624 extension1_->id())); | 1613 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1625 } | 1614 } |
| 1626 | 1615 |
| 1627 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1616 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1628 | 1617 |
| 1629 EXPECT_EQ(3, model_->item_count()); | 1618 EXPECT_EQ(3, model_->item_count()); |
| 1630 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1619 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1631 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1620 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1632 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1621 EXPECT_NE(ash::kInvalidShelfID, |
| 1622 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1633 | 1623 |
| 1634 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1624 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1635 | 1625 |
| 1636 EXPECT_EQ(2, model_->item_count()); | 1626 EXPECT_EQ(2, model_->item_count()); |
| 1637 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1627 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1638 EXPECT_FALSE( | 1628 EXPECT_EQ(ash::kInvalidShelfID, |
| 1639 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1629 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1640 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | |
| 1641 EXPECT_FALSE( | |
| 1642 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | |
| 1643 } | 1630 } |
| 1644 | 1631 |
| 1645 // Check that already pinned items are not effected by locks. | 1632 // Check that already pinned items are not effected by locks. |
| 1646 TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) { | 1633 TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) { |
| 1647 InitLauncherController(); | 1634 InitLauncherController(); |
| 1648 // Model should only contain the browser shortcut and app list items. | 1635 // Model should only contain the browser shortcut and app list items. |
| 1649 EXPECT_EQ(2, model_->item_count()); | 1636 EXPECT_EQ(2, model_->item_count()); |
| 1650 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1637 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1651 EXPECT_FALSE( | 1638 EXPECT_EQ(ash::kInvalidShelfID, |
| 1652 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1639 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1653 | 1640 |
| 1654 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 1655 launcher_controller_->PinAppWithID(extension1_->id()); | 1641 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1656 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | |
| 1657 | 1642 |
| 1658 EXPECT_EQ(3, model_->item_count()); | 1643 EXPECT_EQ(3, model_->item_count()); |
| 1659 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1644 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1660 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1645 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1661 EXPECT_FALSE( | 1646 EXPECT_NE(ash::kInvalidShelfID, |
| 1662 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1647 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1663 | 1648 |
| 1664 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1649 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1665 | 1650 |
| 1666 EXPECT_EQ(3, model_->item_count()); | 1651 EXPECT_EQ(3, model_->item_count()); |
| 1667 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1652 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1668 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1653 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1669 EXPECT_FALSE( | 1654 EXPECT_NE(ash::kInvalidShelfID, |
| 1670 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1655 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1671 | 1656 |
| 1672 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1657 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1673 | 1658 |
| 1674 EXPECT_EQ(3, model_->item_count()); | 1659 EXPECT_EQ(3, model_->item_count()); |
| 1675 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1660 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1676 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1661 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1677 EXPECT_FALSE( | 1662 EXPECT_NE(ash::kInvalidShelfID, |
| 1678 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1663 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1679 | 1664 |
| 1680 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1665 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1681 | 1666 |
| 1682 EXPECT_EQ(2, model_->item_count()); | 1667 EXPECT_EQ(2, model_->item_count()); |
| 1668 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1669 EXPECT_EQ(ash::kInvalidShelfID, |
| 1670 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1683 } | 1671 } |
| 1684 | 1672 |
| 1685 // Check that already pinned items which get locked stay after unpinning. | 1673 // Check that already pinned items which get locked stay after unpinning. |
| 1686 TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) { | 1674 TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) { |
| 1687 InitLauncherController(); | 1675 InitLauncherController(); |
| 1688 // Model should only contain the browser shortcut and app list items. | 1676 // Model should only contain the browser shortcut and app list items. |
| 1689 EXPECT_EQ(2, model_->item_count()); | 1677 EXPECT_EQ(2, model_->item_count()); |
| 1690 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1678 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1691 EXPECT_FALSE( | 1679 EXPECT_EQ(ash::kInvalidShelfID, |
| 1692 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1680 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1693 | 1681 |
| 1694 launcher_controller_->PinAppWithID(extension1_->id()); | 1682 launcher_controller_->PinAppWithID(extension1_->id()); |
| 1695 | 1683 |
| 1696 EXPECT_EQ(3, model_->item_count()); | 1684 EXPECT_EQ(3, model_->item_count()); |
| 1697 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1685 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1698 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1686 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1699 EXPECT_FALSE( | 1687 EXPECT_NE(ash::kInvalidShelfID, |
| 1700 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1688 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1701 | 1689 |
| 1702 launcher_controller_->LockV1AppWithID(extension1_->id()); | 1690 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 1703 | 1691 |
| 1704 EXPECT_EQ(3, model_->item_count()); | 1692 EXPECT_EQ(3, model_->item_count()); |
| 1705 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1693 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1706 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1694 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1707 EXPECT_FALSE( | 1695 EXPECT_NE(ash::kInvalidShelfID, |
| 1708 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1696 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1709 | 1697 |
| 1710 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1698 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 1711 | 1699 |
| 1712 EXPECT_EQ(3, model_->item_count()); | 1700 EXPECT_EQ(3, model_->item_count()); |
| 1713 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 1701 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 1714 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1702 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1715 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1703 EXPECT_NE(ash::kInvalidShelfID, |
| 1704 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1716 | 1705 |
| 1717 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 1706 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 1718 | 1707 |
| 1719 EXPECT_EQ(2, model_->item_count()); | 1708 EXPECT_EQ(2, model_->item_count()); |
| 1709 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1710 EXPECT_EQ(ash::kInvalidShelfID, |
| 1711 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 1720 } | 1712 } |
| 1721 | 1713 |
| 1722 // Check that running applications wich are not pinned get properly restored | 1714 // Check that running applications wich are not pinned get properly restored |
| 1723 // upon user change. | 1715 // upon user change. |
| 1724 TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) { | 1716 TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) { |
| 1725 InitLauncherController(); | 1717 InitLauncherController(); |
| 1726 // Model should only contain the browser shortcut and app list items. | 1718 // Model should only contain the browser shortcut and app list items. |
| 1727 EXPECT_EQ(2, model_->item_count()); | 1719 EXPECT_EQ(2, model_->item_count()); |
| 1728 | 1720 |
| 1729 // Add a few running applications. | 1721 // Add a few running applications. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; | 1769 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; |
| 1778 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; | 1770 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; |
| 1779 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); | 1771 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); |
| 1780 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); | 1772 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); |
| 1781 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); | 1773 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); |
| 1782 | 1774 |
| 1783 SendListOfArcApps(); | 1775 SendListOfArcApps(); |
| 1784 | 1776 |
| 1785 arc_test_.StopArcInstance(); | 1777 arc_test_.StopArcInstance(); |
| 1786 | 1778 |
| 1787 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1779 EXPECT_EQ(ash::kInvalidShelfID, |
| 1788 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1780 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1789 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1781 EXPECT_EQ(ash::kInvalidShelfID, |
| 1782 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1783 EXPECT_EQ(ash::kInvalidShelfID, |
| 1784 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1790 | 1785 |
| 1791 arc::LaunchApp(profile(), arc_app_id1); | 1786 arc::LaunchApp(profile(), arc_app_id1); |
| 1792 arc::LaunchApp(profile(), arc_app_id1); | 1787 arc::LaunchApp(profile(), arc_app_id1); |
| 1793 arc::LaunchApp(profile(), arc_app_id2); | 1788 arc::LaunchApp(profile(), arc_app_id2); |
| 1794 arc::LaunchApp(profile(), arc_app_id3); | 1789 arc::LaunchApp(profile(), arc_app_id3); |
| 1795 arc::LaunchApp(profile(), arc_app_id3); | 1790 arc::LaunchApp(profile(), arc_app_id3); |
| 1796 | 1791 |
| 1797 const ash::ShelfID shelf_id_app_1 = | 1792 const ash::ShelfID shelf_id_app_1 = |
| 1798 launcher_controller_->GetShelfIDForAppID(arc_app_id1); | 1793 launcher_controller_->GetShelfIDForAppID(arc_app_id1); |
| 1799 const ash::ShelfID shelf_id_app_2 = | 1794 const ash::ShelfID shelf_id_app_2 = |
| 1800 launcher_controller_->GetShelfIDForAppID(arc_app_id2); | 1795 launcher_controller_->GetShelfIDForAppID(arc_app_id2); |
| 1801 const ash::ShelfID shelf_id_app_3 = | 1796 const ash::ShelfID shelf_id_app_3 = |
| 1802 launcher_controller_->GetShelfIDForAppID(arc_app_id3); | 1797 launcher_controller_->GetShelfIDForAppID(arc_app_id3); |
| 1803 EXPECT_NE(0, shelf_id_app_1); | 1798 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_1); |
| 1804 EXPECT_NE(0, shelf_id_app_2); | 1799 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_2); |
| 1805 EXPECT_NE(0, shelf_id_app_3); | 1800 EXPECT_NE(ash::kInvalidShelfID, shelf_id_app_3); |
| 1806 | 1801 |
| 1807 // We activated arc_app_id1 twice but expect one close for item controller | 1802 // We activated arc_app_id1 twice but expect one close for item controller |
| 1808 // stops launching request. | 1803 // stops launching request. |
| 1809 LauncherItemController* item_controller = | 1804 LauncherItemController* item_controller = |
| 1810 launcher_controller_->GetLauncherItemController(shelf_id_app_1); | 1805 launcher_controller_->GetLauncherItemController(shelf_id_app_1); |
| 1811 ASSERT_NE(nullptr, item_controller); | 1806 ASSERT_NE(nullptr, item_controller); |
| 1812 item_controller->Close(); | 1807 item_controller->Close(); |
| 1813 base::RunLoop().RunUntilIdle(); | 1808 base::RunLoop().RunUntilIdle(); |
| 1814 | 1809 |
| 1815 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1810 EXPECT_EQ(ash::kInvalidShelfID, |
| 1811 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1816 EXPECT_EQ(shelf_id_app_2, | 1812 EXPECT_EQ(shelf_id_app_2, |
| 1817 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1813 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1818 EXPECT_EQ(shelf_id_app_3, | 1814 EXPECT_EQ(shelf_id_app_3, |
| 1819 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1815 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1820 | 1816 |
| 1821 arc_test_.RestartArcInstance(); | 1817 arc_test_.RestartArcInstance(); |
| 1822 SendListOfArcApps(); | 1818 SendListOfArcApps(); |
| 1823 | 1819 |
| 1824 base::RunLoop().RunUntilIdle(); | 1820 base::RunLoop().RunUntilIdle(); |
| 1825 | 1821 |
| 1826 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1822 EXPECT_EQ(ash::kInvalidShelfID, |
| 1827 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1823 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1828 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1824 EXPECT_EQ(ash::kInvalidShelfID, |
| 1825 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1826 EXPECT_EQ(ash::kInvalidShelfID, |
| 1827 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1829 | 1828 |
| 1830 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); | 1829 ASSERT_EQ(2U, arc_test_.app_instance()->launch_requests().size()); |
| 1831 | 1830 |
| 1832 const arc::FakeAppInstance::Request* request1 = | 1831 const arc::FakeAppInstance::Request* request1 = |
| 1833 arc_test_.app_instance()->launch_requests()[0].get(); | 1832 arc_test_.app_instance()->launch_requests()[0].get(); |
| 1834 const arc::FakeAppInstance::Request* request2 = | 1833 const arc::FakeAppInstance::Request* request2 = |
| 1835 arc_test_.app_instance()->launch_requests()[1].get(); | 1834 arc_test_.app_instance()->launch_requests()[1].get(); |
| 1836 | 1835 |
| 1837 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || | 1836 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || |
| 1838 (request1->IsForApp(app3) && request2->IsForApp(app2))); | 1837 (request1->IsForApp(app3) && request2->IsForApp(app2))); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1859 const std::string arc_app_id1 = | 1858 const std::string arc_app_id1 = |
| 1860 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1859 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1861 const std::string arc_app_id2 = | 1860 const std::string arc_app_id2 = |
| 1862 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 1861 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 1863 const std::string arc_app_id3 = | 1862 const std::string arc_app_id3 = |
| 1864 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); | 1863 ArcAppTest::GetAppId(arc_test_.fake_apps()[2]); |
| 1865 | 1864 |
| 1866 std::string window_app_id1("org.chromium.arc.1"); | 1865 std::string window_app_id1("org.chromium.arc.1"); |
| 1867 views::Widget* arc_window1 = CreateArcWindow(window_app_id1); | 1866 views::Widget* arc_window1 = CreateArcWindow(window_app_id1); |
| 1868 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); | 1867 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); |
| 1869 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1868 EXPECT_NE(ash::kInvalidShelfID, |
| 1869 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1870 | 1870 |
| 1871 std::string window_app_id2("org.chromium.arc.2"); | 1871 std::string window_app_id2("org.chromium.arc.2"); |
| 1872 views::Widget* arc_window2 = CreateArcWindow(window_app_id2); | 1872 views::Widget* arc_window2 = CreateArcWindow(window_app_id2); |
| 1873 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1]); | 1873 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1]); |
| 1874 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1874 EXPECT_NE(ash::kInvalidShelfID, |
| 1875 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1875 | 1876 |
| 1876 launcher_controller_->SetProfileForTest(profile2); | 1877 launcher_controller_->SetProfileForTest(profile2); |
| 1877 SwitchActiveUser(account_id2); | 1878 SwitchActiveUser(account_id2); |
| 1878 | 1879 |
| 1879 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1880 EXPECT_EQ(ash::kInvalidShelfID, |
| 1880 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1881 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1882 EXPECT_EQ(ash::kInvalidShelfID, |
| 1883 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1881 | 1884 |
| 1882 std::string window_app_id3("org.chromium.arc.3"); | 1885 std::string window_app_id3("org.chromium.arc.3"); |
| 1883 views::Widget* arc_window3 = CreateArcWindow(window_app_id3); | 1886 views::Widget* arc_window3 = CreateArcWindow(window_app_id3); |
| 1884 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[2]); | 1887 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[2]); |
| 1885 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1888 EXPECT_EQ(ash::kInvalidShelfID, |
| 1889 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1886 | 1890 |
| 1887 arc_window2->CloseNow(); | 1891 arc_window2->CloseNow(); |
| 1888 arc_test_.app_instance()->SendTaskDestroyed(2); | 1892 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 1889 | 1893 |
| 1890 launcher_controller_->SetProfileForTest(profile()); | 1894 launcher_controller_->SetProfileForTest(profile()); |
| 1891 SwitchActiveUser(account_id); | 1895 SwitchActiveUser(account_id); |
| 1892 | 1896 |
| 1893 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1897 EXPECT_NE(ash::kInvalidShelfID, |
| 1894 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1898 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1895 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id3)); | 1899 EXPECT_EQ(ash::kInvalidShelfID, |
| 1900 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1901 EXPECT_NE(ash::kInvalidShelfID, |
| 1902 launcher_controller_->GetShelfIDForAppID(arc_app_id3)); |
| 1896 | 1903 |
| 1897 // Close active window to let test passes. | 1904 // Close active window to let test passes. |
| 1898 arc_window1->CloseNow(); | 1905 arc_window1->CloseNow(); |
| 1899 arc_window3->CloseNow(); | 1906 arc_window3->CloseNow(); |
| 1900 } | 1907 } |
| 1901 | 1908 |
| 1902 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { | 1909 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRunningApp) { |
| 1903 InitLauncherController(); | 1910 InitLauncherController(); |
| 1904 | 1911 |
| 1905 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1912 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1906 SendListOfArcApps(); | 1913 SendListOfArcApps(); |
| 1907 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1914 EXPECT_EQ(ash::kInvalidShelfID, |
| 1915 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1908 | 1916 |
| 1909 // Normal flow, create/destroy tasks. | 1917 // Normal flow, create/destroy tasks. |
| 1910 std::string window_app_id1("org.chromium.arc.1"); | 1918 std::string window_app_id1("org.chromium.arc.1"); |
| 1911 std::string window_app_id2("org.chromium.arc.2"); | 1919 std::string window_app_id2("org.chromium.arc.2"); |
| 1912 std::string window_app_id3("org.chromium.arc.3"); | 1920 std::string window_app_id3("org.chromium.arc.3"); |
| 1913 CreateArcWindow(window_app_id1); | 1921 CreateArcWindow(window_app_id1); |
| 1914 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); | 1922 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); |
| 1915 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1923 EXPECT_NE(ash::kInvalidShelfID, |
| 1924 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1916 CreateArcWindow(window_app_id2); | 1925 CreateArcWindow(window_app_id2); |
| 1917 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0]); | 1926 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0]); |
| 1918 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1927 EXPECT_NE(ash::kInvalidShelfID, |
| 1928 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1919 arc_test_.app_instance()->SendTaskDestroyed(1); | 1929 arc_test_.app_instance()->SendTaskDestroyed(1); |
| 1920 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1930 EXPECT_NE(ash::kInvalidShelfID, |
| 1931 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1921 arc_test_.app_instance()->SendTaskDestroyed(2); | 1932 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 1922 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1933 EXPECT_EQ(ash::kInvalidShelfID, |
| 1934 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1923 | 1935 |
| 1924 // Stopping bridge removes apps. | 1936 // Stopping bridge removes apps. |
| 1925 CreateArcWindow(window_app_id3); | 1937 CreateArcWindow(window_app_id3); |
| 1926 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); | 1938 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); |
| 1927 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1939 EXPECT_NE(ash::kInvalidShelfID, |
| 1940 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1928 arc_test_.StopArcInstance(); | 1941 arc_test_.StopArcInstance(); |
| 1929 base::RunLoop().RunUntilIdle(); | 1942 base::RunLoop().RunUntilIdle(); |
| 1930 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 1943 EXPECT_EQ(ash::kInvalidShelfID, |
| 1944 launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1931 } | 1945 } |
| 1932 | 1946 |
| 1933 // Test race creation/deletion of Arc app. | 1947 // Test race creation/deletion of Arc app. |
| 1934 // TODO (khmel): Remove after moving everything to wayland protocol. | 1948 // TODO (khmel): Remove after moving everything to wayland protocol. |
| 1935 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { | 1949 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcRaceCreateClose) { |
| 1936 InitLauncherController(); | 1950 InitLauncherController(); |
| 1937 | 1951 |
| 1938 const std::string arc_app_id1 = | 1952 const std::string arc_app_id1 = |
| 1939 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1953 ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1940 const std::string arc_app_id2 = | 1954 const std::string arc_app_id2 = |
| 1941 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); | 1955 ArcAppTest::GetAppId(arc_test_.fake_apps()[1]); |
| 1942 SendListOfArcApps(); | 1956 SendListOfArcApps(); |
| 1943 | 1957 |
| 1944 // Arc window created before and closed after mojom notification. | 1958 // Arc window created before and closed after mojom notification. |
| 1945 std::string window_app_id1("org.chromium.arc.1"); | 1959 std::string window_app_id1("org.chromium.arc.1"); |
| 1946 views::Widget* arc_window = CreateArcWindow(window_app_id1); | 1960 views::Widget* arc_window = CreateArcWindow(window_app_id1); |
| 1947 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1961 EXPECT_EQ(ash::kInvalidShelfID, |
| 1962 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1948 ASSERT_TRUE(arc_window); | 1963 ASSERT_TRUE(arc_window); |
| 1949 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); | 1964 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); |
| 1950 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1965 EXPECT_NE(ash::kInvalidShelfID, |
| 1966 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1951 arc_test_.app_instance()->SendTaskDestroyed(1); | 1967 arc_test_.app_instance()->SendTaskDestroyed(1); |
| 1952 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1968 EXPECT_EQ(ash::kInvalidShelfID, |
| 1969 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1953 arc_window->Close(); | 1970 arc_window->Close(); |
| 1954 base::RunLoop().RunUntilIdle(); | 1971 base::RunLoop().RunUntilIdle(); |
| 1955 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id1)); | 1972 EXPECT_EQ(ash::kInvalidShelfID, |
| 1973 launcher_controller_->GetShelfIDForAppID(arc_app_id1)); |
| 1956 | 1974 |
| 1957 // Arc window created after and closed before mojom notification. | 1975 // Arc window created after and closed before mojom notification. |
| 1958 std::string window_app_id2("org.chromium.arc.2"); | 1976 std::string window_app_id2("org.chromium.arc.2"); |
| 1959 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1]); | 1977 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[1]); |
| 1960 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1978 EXPECT_NE(ash::kInvalidShelfID, |
| 1979 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1961 arc_window = CreateArcWindow(window_app_id2); | 1980 arc_window = CreateArcWindow(window_app_id2); |
| 1962 ASSERT_TRUE(arc_window); | 1981 ASSERT_TRUE(arc_window); |
| 1963 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1982 EXPECT_NE(ash::kInvalidShelfID, |
| 1983 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1964 arc_window->Close(); | 1984 arc_window->Close(); |
| 1965 base::RunLoop().RunUntilIdle(); | 1985 base::RunLoop().RunUntilIdle(); |
| 1966 // Closing window does not close shelf item. It is closed on task destroy. | 1986 // Closing window does not close shelf item. It is closed on task destroy. |
| 1967 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1987 EXPECT_NE(ash::kInvalidShelfID, |
| 1988 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1968 arc_test_.app_instance()->SendTaskDestroyed(2); | 1989 arc_test_.app_instance()->SendTaskDestroyed(2); |
| 1969 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id2)); | 1990 EXPECT_EQ(ash::kInvalidShelfID, |
| 1991 launcher_controller_->GetShelfIDForAppID(arc_app_id2)); |
| 1970 } | 1992 } |
| 1971 | 1993 |
| 1972 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { | 1994 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcWindowRecreation) { |
| 1973 InitLauncherController(); | 1995 InitLauncherController(); |
| 1974 | 1996 |
| 1975 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); | 1997 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); |
| 1976 SendListOfArcApps(); | 1998 SendListOfArcApps(); |
| 1977 | 1999 |
| 1978 std::string window_app_id("org.chromium.arc.1"); | 2000 std::string window_app_id("org.chromium.arc.1"); |
| 1979 views::Widget* arc_window = CreateArcWindow(window_app_id); | 2001 views::Widget* arc_window = CreateArcWindow(window_app_id); |
| 1980 ASSERT_TRUE(arc_window); | 2002 ASSERT_TRUE(arc_window); |
| 1981 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); | 2003 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); |
| 1982 const ash::ShelfID shelf_id = | 2004 const ash::ShelfID shelf_id = |
| 1983 launcher_controller_->GetShelfIDForAppID(arc_app_id); | 2005 launcher_controller_->GetShelfIDForAppID(arc_app_id); |
| 1984 EXPECT_NE(0, shelf_id); | 2006 EXPECT_NE(ash::kInvalidShelfID, shelf_id); |
| 1985 | 2007 |
| 1986 for (int i = 0; i < 3; ++i) { | 2008 for (int i = 0; i < 3; ++i) { |
| 1987 arc_window->Close(); | 2009 arc_window->Close(); |
| 1988 base::RunLoop().RunUntilIdle(); | 2010 base::RunLoop().RunUntilIdle(); |
| 1989 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2011 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| 1990 | 2012 |
| 1991 arc_window = CreateArcWindow(window_app_id); | 2013 arc_window = CreateArcWindow(window_app_id); |
| 1992 ASSERT_TRUE(arc_window); | 2014 ASSERT_TRUE(arc_window); |
| 1993 base::RunLoop().RunUntilIdle(); | 2015 base::RunLoop().RunUntilIdle(); |
| 1994 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); | 2016 EXPECT_EQ(shelf_id, launcher_controller_->GetShelfIDForAppID(arc_app_id)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2274 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); | 2296 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); |
| 2275 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); | 2297 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); |
| 2276 } | 2298 } |
| 2277 | 2299 |
| 2278 // Check that lock -> pin -> unlock -> unpin does properly transition. | 2300 // Check that lock -> pin -> unlock -> unpin does properly transition. |
| 2279 TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) { | 2301 TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) { |
| 2280 InitLauncherController(); | 2302 InitLauncherController(); |
| 2281 // Model should only contain the browser shortcut and app list items. | 2303 // Model should only contain the browser shortcut and app list items. |
| 2282 EXPECT_EQ(2, model_->item_count()); | 2304 EXPECT_EQ(2, model_->item_count()); |
| 2283 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2305 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2284 EXPECT_FALSE( | 2306 EXPECT_EQ(ash::kInvalidShelfID, |
| 2285 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 2307 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2286 | 2308 |
| 2287 launcher_controller_->LockV1AppWithID(extension1_->id()); | 2309 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 2288 | 2310 |
| 2289 EXPECT_EQ(3, model_->item_count()); | 2311 EXPECT_EQ(3, model_->item_count()); |
| 2290 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); | 2312 EXPECT_EQ(ash::TYPE_APP, model_->items()[2].type); |
| 2291 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 2313 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2292 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 2314 EXPECT_NE(ash::kInvalidShelfID, |
| 2315 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2293 | 2316 |
| 2294 launcher_controller_->PinAppWithID(extension1_->id()); | 2317 launcher_controller_->PinAppWithID(extension1_->id()); |
| 2295 | 2318 |
| 2296 EXPECT_EQ(3, model_->item_count()); | 2319 EXPECT_EQ(3, model_->item_count()); |
| 2297 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 2320 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 2298 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2321 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2299 EXPECT_FALSE( | 2322 EXPECT_NE(ash::kInvalidShelfID, |
| 2300 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 2323 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2301 | 2324 |
| 2302 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 2325 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 2303 | 2326 |
| 2304 EXPECT_EQ(3, model_->item_count()); | 2327 EXPECT_EQ(3, model_->item_count()); |
| 2305 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 2328 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 2306 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 2329 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2307 EXPECT_FALSE( | 2330 EXPECT_NE(ash::kInvalidShelfID, |
| 2308 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 2331 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2309 | 2332 |
| 2310 launcher_controller_->UnpinAppWithID(extension1_->id()); | 2333 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 2311 | 2334 |
| 2312 EXPECT_EQ(2, model_->item_count()); | 2335 EXPECT_EQ(2, model_->item_count()); |
| 2336 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 2337 EXPECT_EQ(ash::kInvalidShelfID, |
| 2338 launcher_controller_->GetShelfIDForAppID(extension1_->id())); |
| 2313 } | 2339 } |
| 2314 | 2340 |
| 2315 // Check that a locked (windowed V1 application) will be properly converted | 2341 // Check that a locked (windowed V1 application) will be properly converted |
| 2316 // between locked and pinned when the order gets changed through a profile / | 2342 // between locked and pinned when the order gets changed through a profile / |
| 2317 // policy change. | 2343 // policy change. |
| 2318 TEST_F(ChromeLauncherControllerImplTest, | 2344 TEST_F(ChromeLauncherControllerImplTest, |
| 2319 RestoreDefaultAndLockedAppsResyncOrder) { | 2345 RestoreDefaultAndLockedAppsResyncOrder) { |
| 2320 InitLauncherController(); | 2346 InitLauncherController(); |
| 2321 | 2347 |
| 2322 syncer::SyncChangeList sync_list; | 2348 syncer::SyncChangeList sync_list; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2368 TEST_F(ChromeLauncherControllerImplTest, | 2394 TEST_F(ChromeLauncherControllerImplTest, |
| 2369 RestoreDefaultAndRunningV2AppsResyncOrder) { | 2395 RestoreDefaultAndRunningV2AppsResyncOrder) { |
| 2370 InitLauncherController(); | 2396 InitLauncherController(); |
| 2371 syncer::SyncChangeList sync_list0; | 2397 syncer::SyncChangeList sync_list0; |
| 2372 InsertAddPinChange(&sync_list0, 0, extension1_->id()); | 2398 InsertAddPinChange(&sync_list0, 0, extension1_->id()); |
| 2373 InsertAddPinChange(&sync_list0, 1, extension3_->id()); | 2399 InsertAddPinChange(&sync_list0, 1, extension3_->id()); |
| 2374 SendPinChanges(sync_list0, true); | 2400 SendPinChanges(sync_list0, true); |
| 2375 // The shelf layout has always one static item at the beginning (app List). | 2401 // The shelf layout has always one static item at the beginning (app List). |
| 2376 extension_service_->AddExtension(extension1_.get()); | 2402 extension_service_->AddExtension(extension1_.get()); |
| 2377 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 2403 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
| 2378 extension_service_->AddExtension(extension2_.get()); | 2404 extension_service_->AddExtension(extension_platform_app_.get()); |
| 2379 // No new app icon will be generated. | 2405 // No new app icon will be generated. |
| 2380 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 2406 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
| 2381 // Add the app as an unpinned but running V2 app. | 2407 // Add an unpinned but running V2 app. |
| 2382 CreateRunningV2App(extension2_->id()); | 2408 CreateRunningV2App(extension_platform_app_->id()); |
| 2383 EXPECT_EQ("AppList, Chrome, App1, *app2", GetPinnedAppStatus()); | 2409 EXPECT_EQ("AppList, Chrome, App1, *platform_app", GetPinnedAppStatus()); |
| 2384 extension_service_->AddExtension(extension3_.get()); | 2410 extension_service_->AddExtension(extension3_.get()); |
| 2385 EXPECT_EQ("AppList, Chrome, App1, App3, *app2", GetPinnedAppStatus()); | 2411 EXPECT_EQ("AppList, Chrome, App1, App3, *platform_app", GetPinnedAppStatus()); |
| 2386 | 2412 |
| 2387 // Now request to pin all items which should convert the locked item into a | 2413 // Now request to pin all items which should convert the locked item into a |
| 2388 // pinned item. | 2414 // pinned item. |
| 2389 syncer::SyncChangeList sync_list1; | 2415 syncer::SyncChangeList sync_list1; |
| 2390 InsertAddPinChange(&sync_list1, 0, extension3_->id()); | 2416 InsertAddPinChange(&sync_list1, 0, extension3_->id()); |
| 2391 InsertAddPinChange(&sync_list1, 1, extension2_->id()); | 2417 InsertAddPinChange(&sync_list1, 1, extension_platform_app_->id()); |
| 2392 InsertAddPinChange(&sync_list1, 2, extension1_->id()); | 2418 InsertAddPinChange(&sync_list1, 2, extension1_->id()); |
| 2393 SendPinChanges(sync_list1, true); | 2419 SendPinChanges(sync_list1, true); |
| 2394 EXPECT_EQ("AppList, Chrome, App3, App2, App1", GetPinnedAppStatus()); | 2420 EXPECT_EQ("AppList, Chrome, App3, *Platform_App, App1", GetPinnedAppStatus()); |
| 2395 | 2421 |
| 2396 // Going back to a status where there is no requirement for app 2 to be pinned | 2422 // 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 | 2423 // 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. | 2424 // determined by the |ShelfModel|'s weight system, it will be after last |
| 2425 // pinned item. |
| 2399 syncer::SyncChangeList sync_list2; | 2426 syncer::SyncChangeList sync_list2; |
| 2400 InsertAddPinChange(&sync_list2, 0, extension3_->id()); | 2427 InsertAddPinChange(&sync_list2, 0, extension3_->id()); |
| 2401 InsertAddPinChange(&sync_list2, 1, extension1_->id()); | 2428 InsertAddPinChange(&sync_list2, 1, extension1_->id()); |
| 2402 SendPinChanges(sync_list2, true); | 2429 SendPinChanges(sync_list2, true); |
| 2403 EXPECT_EQ("AppList, Chrome, App3, App1, *app2", GetPinnedAppStatus()); | 2430 EXPECT_EQ("AppList, Chrome, App3, App1, *platform_app", GetPinnedAppStatus()); |
| 2404 | 2431 |
| 2405 // Removing an item should simply close it and everything should shift. | 2432 // Removing an item should simply close it and everything should shift. |
| 2406 syncer::SyncChangeList sync_list3; | 2433 syncer::SyncChangeList sync_list3; |
| 2407 InsertAddPinChange(&sync_list3, 0, extension3_->id()); | 2434 InsertAddPinChange(&sync_list3, 0, extension3_->id()); |
| 2408 SendPinChanges(sync_list3, true); | 2435 SendPinChanges(sync_list3, true); |
| 2409 EXPECT_EQ("AppList, Chrome, App3, *app2", GetPinnedAppStatus()); | 2436 EXPECT_EQ("AppList, Chrome, App3, *platform_app", GetPinnedAppStatus()); |
| 2410 } | 2437 } |
| 2411 | 2438 |
| 2412 // Each user has a different set of applications pinned. Check that when | 2439 // Each user has a different set of applications pinned. Check that when |
| 2413 // switching between the two users, the state gets properly set. | 2440 // switching between the two users, the state gets properly set. |
| 2414 TEST_F(ChromeLauncherControllerImplTest, UserSwitchIconRestore) { | 2441 TEST_F(ChromeLauncherControllerImplTest, UserSwitchIconRestore) { |
| 2415 syncer::SyncChangeList user_a; | 2442 syncer::SyncChangeList user_a; |
| 2416 syncer::SyncChangeList user_b; | 2443 syncer::SyncChangeList user_b; |
| 2417 | 2444 |
| 2418 SetUpMultiUserScenario(&user_a, &user_b); | 2445 SetUpMultiUserScenario(&user_a, &user_b); |
| 2419 | 2446 |
| 2420 // Show user 1. | 2447 // Show user 1. |
| 2421 SendPinChanges(user_a, true); | 2448 SendPinChanges(user_a, true); |
| 2422 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", | 2449 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", |
| 2423 GetPinnedAppStatus()); | 2450 GetPinnedAppStatus()); |
| 2424 | 2451 |
| 2425 // Show user 2. | 2452 // Show user 2. |
| 2426 SendPinChanges(user_b, true); | 2453 SendPinChanges(user_b, true); |
| 2427 EXPECT_EQ("AppList, App7, App8, Chrome", GetPinnedAppStatus()); | 2454 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus()); |
| 2428 | 2455 |
| 2429 // Switch back to 1. | 2456 // Switch back to 1. |
| 2430 SendPinChanges(user_a, true); | 2457 SendPinChanges(user_a, true); |
| 2431 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", | 2458 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", |
| 2432 GetPinnedAppStatus()); | 2459 GetPinnedAppStatus()); |
| 2433 | 2460 |
| 2434 // Switch back to 2. | 2461 // Switch back to 2. |
| 2435 SendPinChanges(user_b, true); | 2462 SendPinChanges(user_b, true); |
| 2436 EXPECT_EQ("AppList, App7, App8, Chrome", GetPinnedAppStatus()); | 2463 EXPECT_EQ("AppList, App6, App7, App8, Chrome", GetPinnedAppStatus()); |
| 2437 } | 2464 } |
| 2438 | 2465 |
| 2439 // Each user has a different set of applications pinned, and one user has an | 2466 // 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 | 2467 // application running. Check that when switching between the two users, the |
| 2441 // state gets properly set. | 2468 // state gets properly set. |
| 2442 TEST_F(ChromeLauncherControllerImplTest, | 2469 TEST_F(ChromeLauncherControllerImplTest, |
| 2443 UserSwitchIconRestoreWithRunningV2App) { | 2470 UserSwitchIconRestoreWithRunningV2App) { |
| 2444 syncer::SyncChangeList user_a; | 2471 syncer::SyncChangeList user_a; |
| 2445 syncer::SyncChangeList user_b; | 2472 syncer::SyncChangeList user_b; |
| 2446 | 2473 |
| 2447 SetUpMultiUserScenario(&user_a, &user_b); | 2474 SetUpMultiUserScenario(&user_a, &user_b); |
| 2448 | 2475 |
| 2449 // Run App1 and assume that it is a V2 app. | 2476 // Run the platform (V2) app. |
| 2450 CreateRunningV2App(extension1_->id()); | 2477 CreateRunningV2App(extension_platform_app_->id()); |
| 2451 | 2478 |
| 2452 // Show user 1. | 2479 // Show user 1. |
| 2453 SendPinChanges(user_a, true); | 2480 SendPinChanges(user_a, true); |
| 2454 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", | 2481 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", |
| 2455 GetPinnedAppStatus()); | 2482 GetPinnedAppStatus()); |
| 2456 | 2483 |
| 2457 // Show user 2. | 2484 // Show user 2. |
| 2458 SendPinChanges(user_b, true); | 2485 SendPinChanges(user_b, true); |
| 2459 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus()); | 2486 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", |
| 2487 GetPinnedAppStatus()); |
| 2460 | 2488 |
| 2461 // Switch back to 1. | 2489 // Switch back to 1. |
| 2462 SendPinChanges(user_a, true); | 2490 SendPinChanges(user_a, true); |
| 2463 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", | 2491 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, App5, Chrome", |
| 2464 GetPinnedAppStatus()); | 2492 GetPinnedAppStatus()); |
| 2465 | 2493 |
| 2466 // Switch back to 2. | 2494 // Switch back to 2. |
| 2467 SendPinChanges(user_b, true); | 2495 SendPinChanges(user_b, true); |
| 2468 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus()); | 2496 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", |
| 2497 GetPinnedAppStatus()); |
| 2469 } | 2498 } |
| 2470 | 2499 |
| 2471 // Each user has a different set of applications pinned, and one user has an | 2500 // 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. | 2501 // 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. | 2502 // Check that when switching between the two users, the state gets properly set. |
| 2474 // There was once a bug associated with this. | 2503 // There was once a bug associated with this. |
| 2475 TEST_F(ChromeLauncherControllerImplTest, | 2504 TEST_F(ChromeLauncherControllerImplTest, |
| 2476 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) { | 2505 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) { |
| 2477 syncer::SyncChangeList user_a; | 2506 syncer::SyncChangeList user_a; |
| 2478 syncer::SyncChangeList user_b; | 2507 syncer::SyncChangeList user_b; |
| 2479 SetUpMultiUserScenario(&user_a, &user_b); | 2508 SetUpMultiUserScenario(&user_a, &user_b); |
| 2480 | 2509 |
| 2481 // Run App1 and assume that it is a V2 app. | 2510 // Run the platform (V2) app. |
| 2482 CreateRunningV2App(extension1_->id()); | 2511 CreateRunningV2App(extension_platform_app_->id()); |
| 2483 | 2512 |
| 2484 // Show user 1. | 2513 // Show user 1. |
| 2485 SendPinChanges(user_a, true); | 2514 SendPinChanges(user_a, true); |
| 2486 SetShelfChromeIconIndex(5); | 2515 SetShelfChromeIconIndex(5); |
| 2487 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, Chrome, App6", | 2516 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5", |
| 2488 GetPinnedAppStatus()); | 2517 GetPinnedAppStatus()); |
| 2489 | 2518 |
| 2490 // Show user 2. | 2519 // Show user 2. |
| 2491 SendPinChanges(user_b, true); | 2520 SendPinChanges(user_b, true); |
| 2492 SetShelfChromeIconIndex(4); | 2521 SetShelfChromeIconIndex(4); |
| 2493 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus()); | 2522 EXPECT_EQ("AppList, App6, App7, App8, Chrome, *platform_app", |
| 2523 GetPinnedAppStatus()); |
| 2494 | 2524 |
| 2495 // Switch back to 1. | 2525 // Switch back to 1. |
| 2496 SendPinChanges(user_a, true); | 2526 SendPinChanges(user_a, true); |
| 2497 SetShelfChromeIconIndex(5); | 2527 SetShelfChromeIconIndex(5); |
| 2498 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, Chrome, App6", | 2528 EXPECT_EQ("AppList, App1, App2, App3, *Platform_App, App4, Chrome, App5", |
| 2499 GetPinnedAppStatus()); | 2529 GetPinnedAppStatus()); |
| 2500 } | 2530 } |
| 2501 | 2531 |
| 2502 TEST_F(ChromeLauncherControllerImplTest, Policy) { | 2532 TEST_F(ChromeLauncherControllerImplTest, Policy) { |
| 2503 extension_service_->AddExtension(extension1_.get()); | 2533 extension_service_->AddExtension(extension1_.get()); |
| 2504 extension_service_->AddExtension(extension3_.get()); | 2534 extension_service_->AddExtension(extension3_.get()); |
| 2505 | 2535 |
| 2506 InitLauncherController(); | 2536 InitLauncherController(); |
| 2507 | 2537 |
| 2508 syncer::SyncChangeList sync_list; | 2538 syncer::SyncChangeList sync_list; |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3274 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher. | 3304 // Make an app panel; the ShelfItem is added by ash::ShelfWindowWatcher. |
| 3275 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>( | 3305 std::unique_ptr<V2App> app_panel1 = base::MakeUnique<V2App>( |
| 3276 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL); | 3306 profile(), extension1_.get(), extensions::AppWindow::WINDOW_TYPE_PANEL); |
| 3277 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible()); | 3307 EXPECT_TRUE(app_panel1->window()->GetNativeWindow()->IsVisible()); |
| 3278 int panel_index = model_observer_->last_index(); | 3308 int panel_index = model_observer_->last_index(); |
| 3279 EXPECT_EQ(1, model_observer_->added()); | 3309 EXPECT_EQ(1, model_observer_->added()); |
| 3280 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3310 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 3281 model_observer_->clear_counts(); | 3311 model_observer_->clear_counts(); |
| 3282 | 3312 |
| 3283 // App panels should have a separate identifier than the app id | 3313 // App panels should have a separate identifier than the app id |
| 3284 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 3314 EXPECT_EQ(ash::kInvalidShelfID, |
| 3315 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3285 | 3316 |
| 3286 // Setting the app image should not change the panel, which has a window icon. | 3317 // Setting the app image should not change the panel, which has a window icon. |
| 3287 gfx::ImageSkia image; | 3318 gfx::ImageSkia image; |
| 3288 launcher_controller_->OnAppImageUpdated(app_id, image); | 3319 launcher_controller_->OnAppImageUpdated(app_id, image); |
| 3289 EXPECT_EQ(0, model_observer_->changed()); | 3320 EXPECT_EQ(0, model_observer_->changed()); |
| 3290 model_observer_->clear_counts(); | 3321 model_observer_->clear_counts(); |
| 3291 | 3322 |
| 3292 // Make a second app panel and verify that it gets the same index as the first | 3323 // Make a second app panel and verify that it gets the same index as the first |
| 3293 // panel, being added to the left of the existing panel. | 3324 // panel, being added to the left of the existing panel. |
| 3294 std::unique_ptr<V2App> app_panel2 = base::MakeUnique<V2App>( | 3325 std::unique_ptr<V2App> app_panel2 = base::MakeUnique<V2App>( |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3925 arc::ArcSessionManager::SetShelfDelegateForTesting( | 3956 arc::ArcSessionManager::SetShelfDelegateForTesting( |
| 3926 launcher_controller_.get()); | 3957 launcher_controller_.get()); |
| 3927 | 3958 |
| 3928 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); | 3959 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); |
| 3929 EnableArc(false); | 3960 EnableArc(false); |
| 3930 EXPECT_FALSE(arc_test_.arc_session_manager()->IsArcEnabled()); | 3961 EXPECT_FALSE(arc_test_.arc_session_manager()->IsArcEnabled()); |
| 3931 ASSERT_TRUE(prefs->GetAppIds().size()); | 3962 ASSERT_TRUE(prefs->GetAppIds().size()); |
| 3932 | 3963 |
| 3933 const std::string app_id = | 3964 const std::string app_id = |
| 3934 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); | 3965 ArcAppTest::GetAppId(arc_test_.fake_default_apps()[0]); |
| 3935 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 3966 EXPECT_EQ(ash::kInvalidShelfID, |
| 3967 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3936 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); | 3968 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); |
| 3937 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcEnabled()); | 3969 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcEnabled()); |
| 3938 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 3970 EXPECT_NE(ash::kInvalidShelfID, |
| 3971 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3939 | 3972 |
| 3940 // Stop Arc again. Shelf item should go away. | 3973 // Stop Arc again. Shelf item should go away. |
| 3941 EnableArc(false); | 3974 EnableArc(false); |
| 3942 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 3975 EXPECT_EQ(ash::kInvalidShelfID, |
| 3976 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3943 | 3977 |
| 3944 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); | 3978 EXPECT_TRUE(arc::LaunchApp(profile(), app_id)); |
| 3945 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcEnabled()); | 3979 EXPECT_TRUE(arc_test_.arc_session_manager()->IsArcEnabled()); |
| 3946 | 3980 |
| 3947 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 3981 EXPECT_NE(ash::kInvalidShelfID, |
| 3982 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3948 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 3983 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 3949 | 3984 |
| 3950 std::string window_app_id("org.chromium.arc.1"); | 3985 std::string window_app_id("org.chromium.arc.1"); |
| 3951 CreateArcWindow(window_app_id); | 3986 CreateArcWindow(window_app_id); |
| 3952 arc_test_.app_instance()->SendTaskCreated(1, | 3987 arc_test_.app_instance()->SendTaskCreated(1, |
| 3953 arc_test_.fake_default_apps()[0]); | 3988 arc_test_.fake_default_apps()[0]); |
| 3954 | 3989 |
| 3955 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 3990 EXPECT_NE(ash::kInvalidShelfID, |
| 3991 launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3956 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 3992 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 3957 } | 3993 } |
| 3958 | 3994 |
| 3959 // Checks the case when several app items have the same ordinal position (which | 3995 // Checks the case when several app items have the same ordinal position (which |
| 3960 // is valid case). | 3996 // is valid case). |
| 3961 TEST_F(ChromeLauncherControllerImplTest, CheckPositionConflict) { | 3997 TEST_F(ChromeLauncherControllerImplTest, CheckPositionConflict) { |
| 3962 InitLauncherController(); | 3998 InitLauncherController(); |
| 3963 | 3999 |
| 3964 extension_service_->AddExtension(extension1_.get()); | 4000 extension_service_->AddExtension(extension1_.get()); |
| 3965 extension_service_->AddExtension(extension2_.get()); | 4001 extension_service_->AddExtension(extension2_.get()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4030 | 4066 |
| 4031 // Pinned state should not change. | 4067 // Pinned state should not change. |
| 4032 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4068 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4033 launcher_controller_->UnpinAppWithID(extension2_->id()); | 4069 launcher_controller_->UnpinAppWithID(extension2_->id()); |
| 4034 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 4070 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
| 4035 | 4071 |
| 4036 // Resume syncing and sync information overrides local copy. | 4072 // Resume syncing and sync information overrides local copy. |
| 4037 StartAppSyncService(copy_sync_list); | 4073 StartAppSyncService(copy_sync_list); |
| 4038 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4074 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
| 4039 } | 4075 } |
| OLD | NEW |