| 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.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 result += "AppList, "; | 329 result += "AppList, "; |
| 330 break; | 330 break; |
| 331 default: | 331 default: |
| 332 result += "Unknown"; | 332 result += "Unknown"; |
| 333 break; | 333 break; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 return result; | 336 return result; |
| 337 } | 337 } |
| 338 | 338 |
| 339 // Set the index at which the chrome icon should be. |
| 340 void SetShelfChromeIconIndex(int index) { |
| 341 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, |
| 342 index + 1); |
| 343 } |
| 344 |
| 339 // Needed for extension service & friends to work. | 345 // Needed for extension service & friends to work. |
| 340 scoped_refptr<Extension> extension1_; | 346 scoped_refptr<Extension> extension1_; |
| 341 scoped_refptr<Extension> extension2_; | 347 scoped_refptr<Extension> extension2_; |
| 342 scoped_refptr<Extension> extension3_; | 348 scoped_refptr<Extension> extension3_; |
| 343 scoped_refptr<Extension> extension4_; | 349 scoped_refptr<Extension> extension4_; |
| 344 scoped_ptr<ChromeLauncherController> launcher_controller_; | 350 scoped_ptr<ChromeLauncherController> launcher_controller_; |
| 345 scoped_ptr<TestLauncherModelObserver> model_observer_; | 351 scoped_ptr<TestLauncherModelObserver> model_observer_; |
| 346 scoped_ptr<ash::LauncherModel> model_; | 352 scoped_ptr<ash::LauncherModel> model_; |
| 347 | 353 |
| 348 ExtensionService* extension_service_; | 354 ExtensionService* extension_service_; |
| 349 | 355 |
| 350 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); | 356 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); |
| 351 }; | 357 }; |
| 352 | 358 |
| 353 // The testing framework to test the alternate shelf layout. | 359 // The testing framework to test the legacy shelf layout. |
| 354 class AlternateLayoutChromeLauncherControllerTest | 360 class LegacyShelfLayoutChromeLauncherControllerTest |
| 355 : public ChromeLauncherControllerTest { | 361 : public ChromeLauncherControllerTest { |
| 356 protected: | 362 protected: |
| 357 AlternateLayoutChromeLauncherControllerTest() { | 363 LegacyShelfLayoutChromeLauncherControllerTest() { |
| 358 } | 364 } |
| 359 | 365 |
| 360 virtual ~AlternateLayoutChromeLauncherControllerTest() { | 366 virtual ~LegacyShelfLayoutChromeLauncherControllerTest() { |
| 361 } | 367 } |
| 362 | 368 |
| 363 // Overwrite the Setup function to add the Alternate Shelf layout option. | 369 // Overwrite the Setup function to use the legacy shelf layout option. |
| 364 virtual void SetUp() OVERRIDE { | 370 virtual void SetUp() OVERRIDE { |
| 365 CommandLine::ForCurrentProcess()->AppendSwitch( | 371 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 366 ash::switches::kAshUseAlternateShelfLayout); | 372 ash::switches::kAshDisableAlternateShelfLayout); |
| 367 ChromeLauncherControllerTest::SetUp(); | 373 ChromeLauncherControllerTest::SetUp(); |
| 368 } | 374 } |
| 369 | 375 |
| 370 // Set the index at which the chrome icon should be. | |
| 371 void SetShelfChromeIconIndex(int index) { | |
| 372 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, | |
| 373 index + 1); | |
| 374 } | |
| 375 | |
| 376 private: | 376 private: |
| 377 | 377 |
| 378 DISALLOW_COPY_AND_ASSIGN(AlternateLayoutChromeLauncherControllerTest); | 378 DISALLOW_COPY_AND_ASSIGN(LegacyShelfLayoutChromeLauncherControllerTest); |
| 379 }; | 379 }; |
| 380 | 380 |
| 381 | 381 |
| 382 TEST_F(ChromeLauncherControllerTest, DefaultApps) { | 382 TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, DefaultApps) { |
| 383 InitLauncherController(); | 383 InitLauncherController(); |
| 384 // Model should only contain the browser shortcut and app list items. | 384 // Model should only contain the browser shortcut and app list items. |
| 385 EXPECT_EQ(2, model_->item_count()); | 385 EXPECT_EQ(2, model_->item_count()); |
| 386 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 386 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 387 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 387 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 388 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 388 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 389 | 389 |
| 390 // Installing |extension3_| should add it to the launcher - behind the | 390 // Installing |extension3_| should add it to the launcher - behind the |
| 391 // chrome icon. | 391 // chrome icon. |
| 392 extension_service_->AddExtension(extension3_.get()); | 392 extension_service_->AddExtension(extension3_.get()); |
| 393 EXPECT_EQ("Chrome, App3, AppList, ", GetPinnedAppStatus()); | 393 EXPECT_EQ("Chrome, App3, AppList, ", GetPinnedAppStatus()); |
| 394 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 394 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 395 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 395 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 396 } | 396 } |
| 397 | 397 |
| 398 // Check that the restauration of launcher items is happening in the same order | 398 // Check that the restauration of launcher items is happening in the same order |
| 399 // as the user has pinned them (on another system) when they are synced reverse | 399 // as the user has pinned them (on another system) when they are synced reverse |
| 400 // order. | 400 // order. |
| 401 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) { | 401 TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, |
| 402 RestoreDefaultAppsReverseOrder) { |
| 402 InitLauncherController(); | 403 InitLauncherController(); |
| 403 | 404 |
| 404 base::ListValue policy_value; | 405 base::ListValue policy_value; |
| 405 InsertPrefValue(&policy_value, 0, extension1_->id()); | 406 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 406 InsertPrefValue(&policy_value, 1, extension2_->id()); | 407 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 407 InsertPrefValue(&policy_value, 2, extension3_->id()); | 408 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 408 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 409 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 409 policy_value.DeepCopy()); | 410 policy_value.DeepCopy()); |
| 410 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); | 411 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); |
| 411 // Model should only contain the browser shortcut and app list items. | 412 // Model should only contain the browser shortcut and app list items. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 430 | 431 |
| 431 // Installing |extension1_| should add it to the launcher - behind the | 432 // Installing |extension1_| should add it to the launcher - behind the |
| 432 // chrome icon, but in first location. | 433 // chrome icon, but in first location. |
| 433 extension_service_->AddExtension(extension1_.get()); | 434 extension_service_->AddExtension(extension1_.get()); |
| 434 EXPECT_EQ("Chrome, App1, App2, App3, AppList, ", GetPinnedAppStatus()); | 435 EXPECT_EQ("Chrome, App1, App2, App3, AppList, ", GetPinnedAppStatus()); |
| 435 } | 436 } |
| 436 | 437 |
| 437 // Check that the restauration of launcher items is happening in the same order | 438 // Check that the restauration of launcher items is happening in the same order |
| 438 // as the user has pinned them (on another system) when they are synced random | 439 // as the user has pinned them (on another system) when they are synced random |
| 439 // order. | 440 // order. |
| 440 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrder) { | 441 TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, |
| 442 RestoreDefaultAppsRandomOrder) { |
| 441 InitLauncherController(); | 443 InitLauncherController(); |
| 442 | 444 |
| 443 base::ListValue policy_value; | 445 base::ListValue policy_value; |
| 444 InsertPrefValue(&policy_value, 0, extension1_->id()); | 446 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 445 InsertPrefValue(&policy_value, 1, extension2_->id()); | 447 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 446 InsertPrefValue(&policy_value, 2, extension3_->id()); | 448 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 447 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 449 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 448 policy_value.DeepCopy()); | 450 policy_value.DeepCopy()); |
| 449 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); | 451 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); |
| 450 // Model should only contain the browser shortcut and app list items. | 452 // Model should only contain the browser shortcut and app list items. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 468 | 470 |
| 469 // Installing |extension3_| should add it to the launcher - behind the | 471 // Installing |extension3_| should add it to the launcher - behind the |
| 470 // chrome icon, but in first location. | 472 // chrome icon, but in first location. |
| 471 extension_service_->AddExtension(extension3_.get()); | 473 extension_service_->AddExtension(extension3_.get()); |
| 472 EXPECT_EQ("Chrome, App1, App2, App3, AppList, ", GetPinnedAppStatus()); | 474 EXPECT_EQ("Chrome, App1, App2, App3, AppList, ", GetPinnedAppStatus()); |
| 473 } | 475 } |
| 474 | 476 |
| 475 // Check that the restauration of launcher items is happening in the same order | 477 // Check that the restauration of launcher items is happening in the same order |
| 476 // as the user has pinned / moved them (on another system) when they are synced | 478 // as the user has pinned / moved them (on another system) when they are synced |
| 477 // random order - including the chrome icon. | 479 // random order - including the chrome icon. |
| 478 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrderChromeMoved) { | 480 TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, |
| 481 RestoreDefaultAppsRandomOrderChromeMoved) { |
| 479 InitLauncherController(); | 482 InitLauncherController(); |
| 480 | 483 |
| 481 base::ListValue policy_value; | 484 base::ListValue policy_value; |
| 482 InsertPrefValue(&policy_value, 0, extension1_->id()); | 485 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 483 InsertPrefValue(&policy_value, 1, extension2_->id()); | 486 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 484 InsertPrefValue(&policy_value, 2, extension3_->id()); | 487 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 485 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 488 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 486 policy_value.DeepCopy()); | 489 policy_value.DeepCopy()); |
| 487 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, | 490 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, |
| 488 1); | 491 1); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 506 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 509 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 507 EXPECT_EQ("App1, Chrome, App2, AppList, ", GetPinnedAppStatus()); | 510 EXPECT_EQ("App1, Chrome, App2, AppList, ", GetPinnedAppStatus()); |
| 508 | 511 |
| 509 // Installing |extension3_| should add it to the launcher - behind the | 512 // Installing |extension3_| should add it to the launcher - behind the |
| 510 // chrome icon, but in first location. | 513 // chrome icon, but in first location. |
| 511 extension_service_->AddExtension(extension3_.get()); | 514 extension_service_->AddExtension(extension3_.get()); |
| 512 EXPECT_EQ("App1, Chrome, App2, App3, AppList, ", GetPinnedAppStatus()); | 515 EXPECT_EQ("App1, Chrome, App2, App3, AppList, ", GetPinnedAppStatus()); |
| 513 } | 516 } |
| 514 | 517 |
| 515 // Check that syncing to a different state does the correct thing. | 518 // Check that syncing to a different state does the correct thing. |
| 516 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsResyncOrder) { | 519 TEST_F(LegacyShelfLayoutChromeLauncherControllerTest, |
| 520 RestoreDefaultAppsResyncOrder) { |
| 517 InitLauncherController(); | 521 InitLauncherController(); |
| 518 base::ListValue policy_value; | 522 base::ListValue policy_value; |
| 519 InsertPrefValue(&policy_value, 0, extension1_->id()); | 523 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 520 InsertPrefValue(&policy_value, 1, extension2_->id()); | 524 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 521 InsertPrefValue(&policy_value, 2, extension3_->id()); | 525 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 522 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 526 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 523 policy_value.DeepCopy()); | 527 policy_value.DeepCopy()); |
| 524 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); | 528 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); |
| 525 extension_service_->AddExtension(extension2_.get()); | 529 extension_service_->AddExtension(extension2_.get()); |
| 526 extension_service_->AddExtension(extension1_.get()); | 530 extension_service_->AddExtension(extension1_.get()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 541 InsertPrefValue(&policy_value2, 0, extension2_->id()); | 545 InsertPrefValue(&policy_value2, 0, extension2_->id()); |
| 542 InsertPrefValue(&policy_value2, 1, extension3_->id()); | 546 InsertPrefValue(&policy_value2, 1, extension3_->id()); |
| 543 InsertPrefValue(&policy_value2, 2, extension1_->id()); | 547 InsertPrefValue(&policy_value2, 2, extension1_->id()); |
| 544 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, | 548 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, |
| 545 1); | 549 1); |
| 546 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 550 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 547 policy_value2.DeepCopy()); | 551 policy_value2.DeepCopy()); |
| 548 EXPECT_EQ("App2, Chrome, App3, App1, AppList, ", GetPinnedAppStatus()); | 552 EXPECT_EQ("App2, Chrome, App3, App1, AppList, ", GetPinnedAppStatus()); |
| 549 } | 553 } |
| 550 | 554 |
| 551 TEST_F(AlternateLayoutChromeLauncherControllerTest, DefaultApps) { | 555 TEST_F(ChromeLauncherControllerTest, DefaultApps) { |
| 552 InitLauncherController(); | 556 InitLauncherController(); |
| 553 // Model should only contain the browser shortcut and app list items. | 557 // Model should only contain the browser shortcut and app list items. |
| 554 EXPECT_EQ(2, model_->item_count()); | 558 EXPECT_EQ(2, model_->item_count()); |
| 555 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 559 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 556 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 560 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 557 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 561 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 558 | 562 |
| 559 // Installing |extension3_| should add it to the launcher - behind the | 563 // Installing |extension3_| should add it to the launcher - behind the |
| 560 // chrome icon. | 564 // chrome icon. |
| 561 extension_service_->AddExtension(extension3_.get()); | 565 extension_service_->AddExtension(extension3_.get()); |
| 562 EXPECT_EQ("AppList, Chrome, App3, ", GetPinnedAppStatus()); | 566 EXPECT_EQ("AppList, Chrome, App3, ", GetPinnedAppStatus()); |
| 563 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 567 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 564 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 568 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 565 } | 569 } |
| 566 | 570 |
| 567 // Check that the restauration of launcher items is happening in the same order | 571 // Check that the restauration of launcher items is happening in the same order |
| 568 // as the user has pinned them (on another system) when they are synced reverse | 572 // as the user has pinned them (on another system) when they are synced reverse |
| 569 // order. | 573 // order. |
| 570 TEST_F(AlternateLayoutChromeLauncherControllerTest, | 574 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) { |
| 571 RestoreDefaultAppsReverseOrder) { | |
| 572 InitLauncherController(); | 575 InitLauncherController(); |
| 573 | 576 |
| 574 base::ListValue policy_value; | 577 base::ListValue policy_value; |
| 575 InsertPrefValue(&policy_value, 0, extension1_->id()); | 578 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 576 InsertPrefValue(&policy_value, 1, extension2_->id()); | 579 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 577 InsertPrefValue(&policy_value, 2, extension3_->id()); | 580 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 578 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 581 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 579 policy_value.DeepCopy()); | 582 policy_value.DeepCopy()); |
| 580 SetShelfChromeIconIndex(0); | 583 SetShelfChromeIconIndex(0); |
| 581 // Model should only contain the browser shortcut and app list items. | 584 // Model should only contain the browser shortcut and app list items. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 600 | 603 |
| 601 // Installing |extension1_| should add it to the launcher - behind the | 604 // Installing |extension1_| should add it to the launcher - behind the |
| 602 // chrome icon, but in first location. | 605 // chrome icon, but in first location. |
| 603 extension_service_->AddExtension(extension1_.get()); | 606 extension_service_->AddExtension(extension1_.get()); |
| 604 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); | 607 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); |
| 605 } | 608 } |
| 606 | 609 |
| 607 // Check that the restauration of launcher items is happening in the same order | 610 // Check that the restauration of launcher items is happening in the same order |
| 608 // as the user has pinned them (on another system) when they are synced random | 611 // as the user has pinned them (on another system) when they are synced random |
| 609 // order. | 612 // order. |
| 610 TEST_F(AlternateLayoutChromeLauncherControllerTest, | 613 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrder) { |
| 611 RestoreDefaultAppsRandomOrder) { | |
| 612 InitLauncherController(); | 614 InitLauncherController(); |
| 613 | 615 |
| 614 base::ListValue policy_value; | 616 base::ListValue policy_value; |
| 615 InsertPrefValue(&policy_value, 0, extension1_->id()); | 617 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 616 InsertPrefValue(&policy_value, 1, extension2_->id()); | 618 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 617 InsertPrefValue(&policy_value, 2, extension3_->id()); | 619 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 618 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 620 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 619 policy_value.DeepCopy()); | 621 policy_value.DeepCopy()); |
| 620 SetShelfChromeIconIndex(0); | 622 SetShelfChromeIconIndex(0); |
| 621 // Model should only contain the browser shortcut and app list items. | 623 // Model should only contain the browser shortcut and app list items. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 638 EXPECT_EQ("AppList, Chrome, App1, App2, ", GetPinnedAppStatus()); | 640 EXPECT_EQ("AppList, Chrome, App1, App2, ", GetPinnedAppStatus()); |
| 639 | 641 |
| 640 // Installing |extension3_| should add it to the launcher - behind the | 642 // Installing |extension3_| should add it to the launcher - behind the |
| 641 // chrome icon, but in first location. | 643 // chrome icon, but in first location. |
| 642 extension_service_->AddExtension(extension3_.get()); | 644 extension_service_->AddExtension(extension3_.get()); |
| 643 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); | 645 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); |
| 644 } | 646 } |
| 645 | 647 |
| 646 // Check that the restauration of launcher items is happening in the same order | 648 // Check that the restauration of launcher items is happening in the same order |
| 647 // as the user has pinned / moved them (on another system) when they are synced | 649 // as the user has pinned / moved them (on another system) when they are synced |
| 648 // random order - including the chrome icon - using the alternate shelf layout. | 650 // random order - including the chrome icon. |
| 649 TEST_F(AlternateLayoutChromeLauncherControllerTest, | 651 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrderChromeMoved) { |
| 650 RestoreDefaultAppsRandomOrderChromeMoved) { | |
| 651 InitLauncherController(); | 652 InitLauncherController(); |
| 652 | 653 |
| 653 base::ListValue policy_value; | 654 base::ListValue policy_value; |
| 654 InsertPrefValue(&policy_value, 0, extension1_->id()); | 655 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 655 InsertPrefValue(&policy_value, 1, extension2_->id()); | 656 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 656 InsertPrefValue(&policy_value, 2, extension3_->id()); | 657 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 657 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 658 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 658 policy_value.DeepCopy()); | 659 policy_value.DeepCopy()); |
| 659 SetShelfChromeIconIndex(1); | 660 SetShelfChromeIconIndex(1); |
| 660 // Model should only contain the browser shortcut and app list items. | 661 // Model should only contain the browser shortcut and app list items. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 676 extension_service_->AddExtension(extension1_.get()); | 677 extension_service_->AddExtension(extension1_.get()); |
| 677 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 678 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 678 EXPECT_EQ("AppList, App1, Chrome, App2, ", GetPinnedAppStatus()); | 679 EXPECT_EQ("AppList, App1, Chrome, App2, ", GetPinnedAppStatus()); |
| 679 | 680 |
| 680 // Installing |extension3_| should add it to the launcher - behind the | 681 // Installing |extension3_| should add it to the launcher - behind the |
| 681 // chrome icon, but in first location. | 682 // chrome icon, but in first location. |
| 682 extension_service_->AddExtension(extension3_.get()); | 683 extension_service_->AddExtension(extension3_.get()); |
| 683 EXPECT_EQ("AppList, App1, Chrome, App2, App3, ", GetPinnedAppStatus()); | 684 EXPECT_EQ("AppList, App1, Chrome, App2, App3, ", GetPinnedAppStatus()); |
| 684 } | 685 } |
| 685 | 686 |
| 686 // Check that syncing to a different state does the correct thing with the | 687 // Check that syncing to a different state does the correct thing. |
| 687 // alternate shelf layout. | 688 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsResyncOrder) { |
| 688 TEST_F(AlternateLayoutChromeLauncherControllerTest, | |
| 689 RestoreDefaultAppsResyncOrder) { | |
| 690 InitLauncherController(); | 689 InitLauncherController(); |
| 691 base::ListValue policy_value; | 690 base::ListValue policy_value; |
| 692 InsertPrefValue(&policy_value, 0, extension1_->id()); | 691 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 693 InsertPrefValue(&policy_value, 1, extension2_->id()); | 692 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 694 InsertPrefValue(&policy_value, 2, extension3_->id()); | 693 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 695 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 694 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 696 policy_value.DeepCopy()); | 695 policy_value.DeepCopy()); |
| 697 // The alternate shelf layout has always one static item at the beginning. | 696 // The shelf layout has always one static item at the beginning (App List). |
| 698 SetShelfChromeIconIndex(0); | 697 SetShelfChromeIconIndex(0); |
| 699 extension_service_->AddExtension(extension2_.get()); | 698 extension_service_->AddExtension(extension2_.get()); |
| 700 EXPECT_EQ("AppList, Chrome, App2, ", GetPinnedAppStatus()); | 699 EXPECT_EQ("AppList, Chrome, App2, ", GetPinnedAppStatus()); |
| 701 extension_service_->AddExtension(extension1_.get()); | 700 extension_service_->AddExtension(extension1_.get()); |
| 702 EXPECT_EQ("AppList, Chrome, App1, App2, ", GetPinnedAppStatus()); | 701 EXPECT_EQ("AppList, Chrome, App1, App2, ", GetPinnedAppStatus()); |
| 703 extension_service_->AddExtension(extension3_.get()); | 702 extension_service_->AddExtension(extension3_.get()); |
| 704 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); | 703 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); |
| 705 | 704 |
| 706 // Change the order with increasing chrome position and decreasing position. | 705 // Change the order with increasing chrome position and decreasing position. |
| 707 base::ListValue policy_value1; | 706 base::ListValue policy_value1; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 753 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 755 EXPECT_FALSE( | 754 EXPECT_FALSE( |
| 756 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 755 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 757 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 756 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 758 EXPECT_FALSE( | 757 EXPECT_FALSE( |
| 759 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 758 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); |
| 760 | 759 |
| 761 launcher_controller_->LockV1AppWithID(extension1_->id()); | 760 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 762 | 761 |
| 763 EXPECT_EQ(3, model_->item_count()); | 762 EXPECT_EQ(3, model_->item_count()); |
| 764 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 763 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 765 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 764 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 766 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 765 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 767 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 766 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 768 EXPECT_FALSE( | 767 EXPECT_FALSE( |
| 769 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 768 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); |
| 770 | 769 |
| 771 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 770 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 772 | 771 |
| 773 EXPECT_EQ(2, model_->item_count()); | 772 EXPECT_EQ(2, model_->item_count()); |
| 774 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 773 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 785 // Model should only contain the browser shortcut and app list items. | 784 // Model should only contain the browser shortcut and app list items. |
| 786 EXPECT_EQ(2, model_->item_count()); | 785 EXPECT_EQ(2, model_->item_count()); |
| 787 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 786 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 788 EXPECT_FALSE( | 787 EXPECT_FALSE( |
| 789 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 788 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 790 | 789 |
| 791 for (int i = 0; i < 2; i++) { | 790 for (int i = 0; i < 2; i++) { |
| 792 launcher_controller_->LockV1AppWithID(extension1_->id()); | 791 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 793 | 792 |
| 794 EXPECT_EQ(3, model_->item_count()); | 793 EXPECT_EQ(3, model_->item_count()); |
| 795 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 794 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 796 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 795 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 797 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher( | 796 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher( |
| 798 extension1_->id())); | 797 extension1_->id())); |
| 799 } | 798 } |
| 800 | 799 |
| 801 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 800 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 802 | 801 |
| 803 EXPECT_EQ(3, model_->item_count()); | 802 EXPECT_EQ(3, model_->item_count()); |
| 804 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 803 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 805 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 804 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 806 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 805 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 807 | 806 |
| 808 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 807 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 809 | 808 |
| 810 EXPECT_EQ(2, model_->item_count()); | 809 EXPECT_EQ(2, model_->item_count()); |
| 811 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 810 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 812 EXPECT_FALSE( | 811 EXPECT_FALSE( |
| 813 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 812 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 814 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 813 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 815 EXPECT_FALSE( | 814 EXPECT_FALSE( |
| 816 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 815 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 817 } | 816 } |
| 818 | 817 |
| 819 // Check that already pinned items are not effected by locks. | 818 // Check that already pinned items are not effected by locks. |
| 820 TEST_F(ChromeLauncherControllerTest, CheckAlreadyPinnedLockApps) { | 819 TEST_F(ChromeLauncherControllerTest, CheckAlreadyPinnedLockApps) { |
| 821 InitLauncherController(); | 820 InitLauncherController(); |
| 822 // Model should only contain the browser shortcut and app list items. | 821 // Model should only contain the browser shortcut and app list items. |
| 823 EXPECT_EQ(2, model_->item_count()); | 822 EXPECT_EQ(2, model_->item_count()); |
| 824 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 823 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 825 EXPECT_FALSE( | 824 EXPECT_FALSE( |
| 826 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 825 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 827 | 826 |
| 828 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 827 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 829 launcher_controller_->PinAppWithID(extension1_->id()); | 828 launcher_controller_->PinAppWithID(extension1_->id()); |
| 830 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 829 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 831 | 830 |
| 832 EXPECT_EQ(3, model_->item_count()); | 831 EXPECT_EQ(3, model_->item_count()); |
| 833 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 832 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 834 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 833 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 835 EXPECT_FALSE( | 834 EXPECT_FALSE( |
| 836 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 835 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 837 | 836 |
| 838 launcher_controller_->LockV1AppWithID(extension1_->id()); | 837 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 839 | 838 |
| 840 EXPECT_EQ(3, model_->item_count()); | 839 EXPECT_EQ(3, model_->item_count()); |
| 841 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 840 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 842 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 841 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 843 EXPECT_FALSE( | 842 EXPECT_FALSE( |
| 844 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 843 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 845 | 844 |
| 846 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 845 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 847 | 846 |
| 848 EXPECT_EQ(3, model_->item_count()); | 847 EXPECT_EQ(3, model_->item_count()); |
| 849 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 848 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 850 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 849 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 851 EXPECT_FALSE( | 850 EXPECT_FALSE( |
| 852 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 851 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 853 | 852 |
| 854 launcher_controller_->UnpinAppWithID(extension1_->id()); | 853 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 855 | 854 |
| 856 EXPECT_EQ(2, model_->item_count()); | 855 EXPECT_EQ(2, model_->item_count()); |
| 857 } | 856 } |
| 858 | 857 |
| 859 // Check that already pinned items which get locked stay after unpinning. | 858 // Check that already pinned items which get locked stay after unpinning. |
| 860 TEST_F(ChromeLauncherControllerTest, CheckPinnedAppsStayAfterUnlock) { | 859 TEST_F(ChromeLauncherControllerTest, CheckPinnedAppsStayAfterUnlock) { |
| 861 InitLauncherController(); | 860 InitLauncherController(); |
| 862 // Model should only contain the browser shortcut and app list items. | 861 // Model should only contain the browser shortcut and app list items. |
| 863 EXPECT_EQ(2, model_->item_count()); | 862 EXPECT_EQ(2, model_->item_count()); |
| 864 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 863 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 865 EXPECT_FALSE( | 864 EXPECT_FALSE( |
| 866 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 865 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 867 | 866 |
| 868 launcher_controller_->PinAppWithID(extension1_->id()); | 867 launcher_controller_->PinAppWithID(extension1_->id()); |
| 869 | 868 |
| 870 EXPECT_EQ(3, model_->item_count()); | 869 EXPECT_EQ(3, model_->item_count()); |
| 871 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 870 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 872 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 871 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 873 EXPECT_FALSE( | 872 EXPECT_FALSE( |
| 874 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 873 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 875 | 874 |
| 876 launcher_controller_->LockV1AppWithID(extension1_->id()); | 875 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 877 | 876 |
| 878 EXPECT_EQ(3, model_->item_count()); | 877 EXPECT_EQ(3, model_->item_count()); |
| 879 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 878 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 880 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 879 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 881 EXPECT_FALSE( | 880 EXPECT_FALSE( |
| 882 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 881 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 883 | 882 |
| 884 launcher_controller_->UnpinAppWithID(extension1_->id()); | 883 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 885 | 884 |
| 886 EXPECT_EQ(3, model_->item_count()); | 885 EXPECT_EQ(3, model_->item_count()); |
| 887 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 886 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 888 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 887 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 889 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 888 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 890 | 889 |
| 891 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 890 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 892 | 891 |
| 893 EXPECT_EQ(2, model_->item_count()); | 892 EXPECT_EQ(2, model_->item_count()); |
| 894 } | 893 } |
| 895 | 894 |
| 896 // Check that lock -> pin -> unlock -> unpin does properly transition. | 895 // Check that lock -> pin -> unlock -> unpin does properly transition. |
| 897 TEST_F(ChromeLauncherControllerTest, CheckLockPinUnlockUnpin) { | 896 TEST_F(ChromeLauncherControllerTest, CheckLockPinUnlockUnpin) { |
| 898 InitLauncherController(); | 897 InitLauncherController(); |
| 899 // Model should only contain the browser shortcut and app list items. | 898 // Model should only contain the browser shortcut and app list items. |
| 900 EXPECT_EQ(2, model_->item_count()); | 899 EXPECT_EQ(2, model_->item_count()); |
| 901 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 900 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 902 EXPECT_FALSE( | 901 EXPECT_FALSE( |
| 903 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 902 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 904 | 903 |
| 905 launcher_controller_->LockV1AppWithID(extension1_->id()); | 904 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 906 | 905 |
| 907 EXPECT_EQ(3, model_->item_count()); | 906 EXPECT_EQ(3, model_->item_count()); |
| 908 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 907 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 909 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 908 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 910 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 909 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 911 | 910 |
| 912 launcher_controller_->PinAppWithID(extension1_->id()); | 911 launcher_controller_->PinAppWithID(extension1_->id()); |
| 913 | 912 |
| 914 EXPECT_EQ(3, model_->item_count()); | 913 EXPECT_EQ(3, model_->item_count()); |
| 915 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 914 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 916 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 915 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 917 EXPECT_FALSE( | 916 EXPECT_FALSE( |
| 918 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 917 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 919 | 918 |
| 920 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 919 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 921 | 920 |
| 922 EXPECT_EQ(3, model_->item_count()); | 921 EXPECT_EQ(3, model_->item_count()); |
| 923 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 922 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 924 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 923 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 925 EXPECT_FALSE( | 924 EXPECT_FALSE( |
| 926 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 925 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 927 | 926 |
| 928 launcher_controller_->UnpinAppWithID(extension1_->id()); | 927 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 929 | 928 |
| 930 EXPECT_EQ(2, model_->item_count()); | 929 EXPECT_EQ(2, model_->item_count()); |
| 931 } | 930 } |
| 932 | 931 |
| 933 TEST_F(ChromeLauncherControllerTest, Policy) { | 932 TEST_F(ChromeLauncherControllerTest, Policy) { |
| 934 extension_service_->AddExtension(extension1_.get()); | 933 extension_service_->AddExtension(extension1_.get()); |
| 935 extension_service_->AddExtension(extension3_.get()); | 934 extension_service_->AddExtension(extension3_.get()); |
| 936 | 935 |
| 937 base::ListValue policy_value; | 936 base::ListValue policy_value; |
| 938 InsertPrefValue(&policy_value, 0, extension1_->id()); | 937 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 939 InsertPrefValue(&policy_value, 1, extension2_->id()); | 938 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 940 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, | 939 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, |
| 941 policy_value.DeepCopy()); | 940 policy_value.DeepCopy()); |
| 942 | 941 |
| 943 // Only |extension1_| should get pinned. |extension2_| is specified but not | 942 // Only |extension1_| should get pinned. |extension2_| is specified but not |
| 944 // installed, and |extension3_| is part of the default set, but that shouldn't | 943 // installed, and |extension3_| is part of the default set, but that shouldn't |
| 945 // take effect when the policy override is in place. | 944 // take effect when the policy override is in place. |
| 946 InitLauncherController(); | 945 InitLauncherController(); |
| 947 EXPECT_EQ(3, model_->item_count()); | 946 EXPECT_EQ(3, model_->item_count()); |
| 948 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 947 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 949 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 948 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 950 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 949 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 951 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 950 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 952 | 951 |
| 953 // Installing |extension2_| should add it to the launcher. | 952 // Installing |extension2_| should add it to the launcher. |
| 954 extension_service_->AddExtension(extension2_.get()); | 953 extension_service_->AddExtension(extension2_.get()); |
| 955 EXPECT_EQ(4, model_->item_count()); | 954 EXPECT_EQ(4, model_->item_count()); |
| 956 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | |
| 957 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 955 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 956 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[3].type); |
| 958 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 957 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 959 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 958 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 960 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 959 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 961 | 960 |
| 962 // Removing |extension1_| from the policy should be reflected in the launcher. | 961 // Removing |extension1_| from the policy should be reflected in the launcher. |
| 963 policy_value.Remove(0, NULL); | 962 policy_value.Remove(0, NULL); |
| 964 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, | 963 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, |
| 965 policy_value.DeepCopy()); | 964 policy_value.DeepCopy()); |
| 966 EXPECT_EQ(3, model_->item_count()); | 965 EXPECT_EQ(3, model_->item_count()); |
| 967 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 966 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 968 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 967 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 969 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 968 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 970 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 969 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 971 } | 970 } |
| 972 | 971 |
| 973 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) { | 972 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) { |
| 974 extension_service_->AddExtension(extension3_.get()); | 973 extension_service_->AddExtension(extension3_.get()); |
| 975 extension_service_->AddExtension(extension4_.get()); | 974 extension_service_->AddExtension(extension4_.get()); |
| 976 | 975 |
| 977 InitLauncherController(); | 976 InitLauncherController(); |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1430 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); | 1429 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); |
| 1431 } | 1430 } |
| 1432 | 1431 |
| 1433 // Verify that the launcher item positions are persisted and restored. | 1432 // Verify that the launcher item positions are persisted and restored. |
| 1434 TEST_F(ChromeLauncherControllerTest, PersistLauncherItemPositions) { | 1433 TEST_F(ChromeLauncherControllerTest, PersistLauncherItemPositions) { |
| 1435 InitLauncherController(); | 1434 InitLauncherController(); |
| 1436 | 1435 |
| 1437 TestAppTabHelperImpl* app_tab_helper = new TestAppTabHelperImpl; | 1436 TestAppTabHelperImpl* app_tab_helper = new TestAppTabHelperImpl; |
| 1438 SetAppTabHelper(app_tab_helper); | 1437 SetAppTabHelper(app_tab_helper); |
| 1439 | 1438 |
| 1440 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[0].type); | 1439 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 1441 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[1].type); | 1440 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[1].type); |
| 1442 | 1441 |
| 1443 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 1442 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
| 1444 EXPECT_EQ(0, tab_strip_model->count()); | 1443 EXPECT_EQ(0, tab_strip_model->count()); |
| 1445 chrome::NewTab(browser()); | 1444 chrome::NewTab(browser()); |
| 1446 chrome::NewTab(browser()); | 1445 chrome::NewTab(browser()); |
| 1447 EXPECT_EQ(2, tab_strip_model->count()); | 1446 EXPECT_EQ(2, tab_strip_model->count()); |
| 1448 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 1447 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 1449 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); | 1448 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); |
| 1450 | 1449 |
| 1451 EXPECT_FALSE(launcher_controller_->IsAppPinned("1")); | 1450 EXPECT_FALSE(launcher_controller_->IsAppPinned("1")); |
| 1452 launcher_controller_->PinAppWithID("1"); | 1451 launcher_controller_->PinAppWithID("1"); |
| 1453 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 1452 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 1454 launcher_controller_->PinAppWithID("2"); | 1453 launcher_controller_->PinAppWithID("2"); |
| 1455 | 1454 |
| 1456 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[0].type); | 1455 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 1456 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[1].type); |
| 1457 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1458 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[3].type); |
| 1459 |
| 1460 // Move browser shortcut item from index 1 to index 3. |
| 1461 model_->Move(1, 3); |
| 1462 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 1457 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 1463 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); |
| 1458 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1464 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1459 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[3].type); | 1465 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); |
| 1460 | 1466 |
| 1461 // Move browser shortcut item from index 0 to index 2. | 1467 // Attempt to move the app list, this should not change anything. |
| 1462 model_->Move(0, 2); | 1468 model_->Move(0, 3); |
| 1463 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[0].type); | 1469 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 1464 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 1470 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); |
| 1465 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[2].type); | 1471 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1466 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[3].type); | 1472 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); |
| 1467 | 1473 |
| 1468 launcher_controller_.reset(); | 1474 launcher_controller_.reset(); |
| 1469 model_.reset(new ash::LauncherModel); | 1475 model_.reset(new ash::LauncherModel); |
| 1470 launcher_controller_.reset( | 1476 launcher_controller_.reset( |
| 1471 ChromeLauncherController::CreateInstance(profile(), model_.get())); | 1477 ChromeLauncherController::CreateInstance(profile(), model_.get())); |
| 1472 app_tab_helper = new TestAppTabHelperImpl; | 1478 app_tab_helper = new TestAppTabHelperImpl; |
| 1473 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 1479 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 1474 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); | 1480 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); |
| 1475 SetAppTabHelper(app_tab_helper); | 1481 SetAppTabHelper(app_tab_helper); |
| 1476 | 1482 |
| 1477 launcher_controller_->Init(); | 1483 launcher_controller_->Init(); |
| 1478 | 1484 |
| 1479 // Check LauncherItems are restored after resetting ChromeLauncherController. | 1485 // Check LauncherItems are restored after resetting ChromeLauncherController. |
| 1480 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[0].type); | 1486 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 1481 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 1487 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); |
| 1482 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[2].type); | 1488 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 1483 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[3].type); | 1489 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); |
| 1484 } | 1490 } |
| 1485 | 1491 |
| 1486 // Verifies pinned apps are persisted and restored. | 1492 // Verifies pinned apps are persisted and restored. |
| 1487 TEST_F(ChromeLauncherControllerTest, PersistPinned) { | 1493 TEST_F(ChromeLauncherControllerTest, PersistPinned) { |
| 1488 InitLauncherControllerWithBrowser(); | 1494 InitLauncherControllerWithBrowser(); |
| 1489 size_t initial_size = model_->items().size(); | 1495 size_t initial_size = model_->items().size(); |
| 1490 | 1496 |
| 1491 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 1497 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
| 1492 EXPECT_EQ(1, tab_strip_model->count()); | 1498 EXPECT_EQ(1, tab_strip_model->count()); |
| 1493 | 1499 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1521 | 1527 |
| 1522 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 1528 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 1523 ASSERT_EQ(initial_size + 1, model_->items().size()); | 1529 ASSERT_EQ(initial_size + 1, model_->items().size()); |
| 1524 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 1530 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 1525 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 1531 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 1526 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 1532 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 1527 | 1533 |
| 1528 launcher_controller_->UnpinAppWithID("1"); | 1534 launcher_controller_->UnpinAppWithID("1"); |
| 1529 ASSERT_EQ(initial_size, model_->items().size()); | 1535 ASSERT_EQ(initial_size, model_->items().size()); |
| 1530 } | 1536 } |
| OLD | NEW |