| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_per_app.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 void InitLauncherControllerWithBrowser() { | 223 void InitLauncherControllerWithBrowser() { |
| 224 chrome::NewTab(browser()); | 224 chrome::NewTab(browser()); |
| 225 BrowserList::SetLastActive(browser()); | 225 BrowserList::SetLastActive(browser()); |
| 226 InitLauncherController(); | 226 InitLauncherController(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void SetAppIconLoader(extensions::AppIconLoader* loader) { | 229 void SetAppIconLoader(extensions::AppIconLoader* loader) { |
| 230 launcher_controller_->SetAppIconLoaderForTest(loader); | 230 launcher_controller_->SetAppIconLoaderForTest(loader); |
| 231 } | 231 } |
| 232 | 232 |
| 233 // Set the index at which the chrome icon should be. |
| 234 void SetShelfChromeIconIndex(int index) { |
| 235 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, |
| 236 index + 1); |
| 237 } |
| 238 |
| 239 |
| 233 void InsertPrefValue(base::ListValue* pref_value, | 240 void InsertPrefValue(base::ListValue* pref_value, |
| 234 int index, | 241 int index, |
| 235 const std::string& extension_id) { | 242 const std::string& extension_id) { |
| 236 base::DictionaryValue* entry = new DictionaryValue(); | 243 base::DictionaryValue* entry = new DictionaryValue(); |
| 237 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id); | 244 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id); |
| 238 pref_value->Insert(index, entry); | 245 pref_value->Insert(index, entry); |
| 239 } | 246 } |
| 240 | 247 |
| 241 // Gets the currently configured app launchers from the controller. | 248 // Gets the currently configured app launchers from the controller. |
| 242 void GetAppLaunchers(ChromeLauncherControllerPerApp* controller, | 249 void GetAppLaunchers(ChromeLauncherControllerPerApp* controller, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 scoped_ptr<ChromeLauncherControllerPerApp> launcher_controller_; | 307 scoped_ptr<ChromeLauncherControllerPerApp> launcher_controller_; |
| 301 scoped_ptr<TestLauncherModelObserver> model_observer_; | 308 scoped_ptr<TestLauncherModelObserver> model_observer_; |
| 302 scoped_ptr<ash::LauncherModel> model_; | 309 scoped_ptr<ash::LauncherModel> model_; |
| 303 | 310 |
| 304 ExtensionService* extension_service_; | 311 ExtensionService* extension_service_; |
| 305 | 312 |
| 306 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerAppTest); | 313 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerPerAppTest); |
| 307 }; | 314 }; |
| 308 | 315 |
| 309 // The testing framework to test the alternate shelf layout. | 316 // The testing framework to test the alternate shelf layout. |
| 310 class AlternateLayoutChromeLauncherControllerPerAppTest | 317 class LegacyShelfLayoutChromeLauncherControllerPerAppTest |
| 311 : public ChromeLauncherControllerPerAppTest { | 318 : public ChromeLauncherControllerPerAppTest { |
| 312 protected: | 319 protected: |
| 313 AlternateLayoutChromeLauncherControllerPerAppTest() { | 320 LegacyShelfLayoutChromeLauncherControllerPerAppTest() { |
| 314 } | 321 } |
| 315 | 322 |
| 316 virtual ~AlternateLayoutChromeLauncherControllerPerAppTest() { | 323 virtual ~LegacyShelfLayoutChromeLauncherControllerPerAppTest() { |
| 317 } | 324 } |
| 318 | 325 |
| 319 // Overwrite the Setup function to add the Alternate Shelf layout option. | 326 // Overwrite the Setup function to add the Alternate Shelf layout option. |
| 320 virtual void SetUp() OVERRIDE { | 327 virtual void SetUp() OVERRIDE { |
| 321 CommandLine::ForCurrentProcess()->AppendSwitch( | 328 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 322 ash::switches::kAshUseAlternateShelfLayout); | 329 ash::switches::kAshDisableAlternateShelfLayout); |
| 323 ChromeLauncherControllerPerAppTest::SetUp(); | 330 ChromeLauncherControllerPerAppTest::SetUp(); |
| 324 } | 331 } |
| 325 | 332 |
| 326 // Set the index at which the chrome icon should be. | |
| 327 void SetShelfChromeIconIndex(int index) { | |
| 328 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, | |
| 329 index + 1); | |
| 330 } | |
| 331 | |
| 332 private: | 333 private: |
| 333 | 334 |
| 334 DISALLOW_COPY_AND_ASSIGN(AlternateLayoutChromeLauncherControllerPerAppTest); | 335 DISALLOW_COPY_AND_ASSIGN(LegacyShelfLayoutChromeLauncherControllerPerAppTest); |
| 335 }; | 336 }; |
| 336 | 337 |
| 337 | 338 |
| 338 TEST_F(ChromeLauncherControllerPerAppTest, DefaultApps) { | 339 TEST_F(LegacyShelfLayoutChromeLauncherControllerPerAppTest, DefaultApps) { |
| 339 InitLauncherController(); | 340 InitLauncherController(); |
| 340 // Model should only contain the browser shortcut and app list items. | 341 // Model should only contain the browser shortcut and app list items. |
| 341 EXPECT_EQ(2, model_->item_count()); | 342 EXPECT_EQ(2, model_->item_count()); |
| 342 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 343 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 343 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 344 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 344 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 345 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 345 | 346 |
| 346 // Installing |extension3_| should add it to the launcher - behind the | 347 // Installing |extension3_| should add it to the launcher - behind the |
| 347 // chrome icon. | 348 // chrome icon. |
| 348 extension_service_->AddExtension(extension3_.get()); | 349 extension_service_->AddExtension(extension3_.get()); |
| 349 EXPECT_EQ("Chrome, App3, AppList, ", GetPinnedAppStatus()); | 350 EXPECT_EQ("Chrome, App3, AppList, ", GetPinnedAppStatus()); |
| 350 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 351 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 351 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 352 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 352 } | 353 } |
| 353 | 354 |
| 354 // Check that the restauration of launcher items is happening in the same order | 355 // Check that the restauration of launcher items is happening in the same order |
| 355 // as the user has pinned them (on another system) when they are synced reverse | 356 // as the user has pinned them (on another system) when they are synced reverse |
| 356 // order. | 357 // order. |
| 357 TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsReverseOrder) { | 358 TEST_F(LegacyShelfLayoutChromeLauncherControllerPerAppTest, |
| 359 RestoreDefaultAppsReverseOrder) { |
| 358 InitLauncherController(); | 360 InitLauncherController(); |
| 359 | 361 |
| 360 base::ListValue policy_value; | 362 base::ListValue policy_value; |
| 361 InsertPrefValue(&policy_value, 0, extension1_->id()); | 363 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 362 InsertPrefValue(&policy_value, 1, extension2_->id()); | 364 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 363 InsertPrefValue(&policy_value, 2, extension3_->id()); | 365 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 364 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 366 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 365 policy_value.DeepCopy()); | 367 policy_value.DeepCopy()); |
| 366 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); | 368 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); |
| 367 // Model should only contain the browser shortcut and app list items. | 369 // Model should only contain the browser shortcut and app list items. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 386 | 388 |
| 387 // Installing |extension1_| should add it to the launcher - behind the | 389 // Installing |extension1_| should add it to the launcher - behind the |
| 388 // chrome icon, but in first location. | 390 // chrome icon, but in first location. |
| 389 extension_service_->AddExtension(extension1_.get()); | 391 extension_service_->AddExtension(extension1_.get()); |
| 390 EXPECT_EQ("Chrome, App1, App2, App3, AppList, ", GetPinnedAppStatus()); | 392 EXPECT_EQ("Chrome, App1, App2, App3, AppList, ", GetPinnedAppStatus()); |
| 391 } | 393 } |
| 392 | 394 |
| 393 // Check that the restauration of launcher items is happening in the same order | 395 // Check that the restauration of launcher items is happening in the same order |
| 394 // as the user has pinned them (on another system) when they are synced random | 396 // as the user has pinned them (on another system) when they are synced random |
| 395 // order. | 397 // order. |
| 396 TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsRandomOrder) { | 398 TEST_F(LegacyShelfLayoutChromeLauncherControllerPerAppTest, |
| 399 RestoreDefaultAppsRandomOrder) { |
| 397 InitLauncherController(); | 400 InitLauncherController(); |
| 398 | 401 |
| 399 base::ListValue policy_value; | 402 base::ListValue policy_value; |
| 400 InsertPrefValue(&policy_value, 0, extension1_->id()); | 403 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 401 InsertPrefValue(&policy_value, 1, extension2_->id()); | 404 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 402 InsertPrefValue(&policy_value, 2, extension3_->id()); | 405 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 403 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 406 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 404 policy_value.DeepCopy()); | 407 policy_value.DeepCopy()); |
| 405 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); | 408 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); |
| 406 // Model should only contain the browser shortcut and app list items. | 409 // Model should only contain the browser shortcut and app list items. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 424 | 427 |
| 425 // Installing |extension3_| should add it to the launcher - behind the | 428 // Installing |extension3_| should add it to the launcher - behind the |
| 426 // chrome icon, but in first location. | 429 // chrome icon, but in first location. |
| 427 extension_service_->AddExtension(extension3_.get()); | 430 extension_service_->AddExtension(extension3_.get()); |
| 428 EXPECT_EQ("Chrome, App1, App2, App3, AppList, ", GetPinnedAppStatus()); | 431 EXPECT_EQ("Chrome, App1, App2, App3, AppList, ", GetPinnedAppStatus()); |
| 429 } | 432 } |
| 430 | 433 |
| 431 // Check that the restauration of launcher items is happening in the same order | 434 // Check that the restauration of launcher items is happening in the same order |
| 432 // as the user has pinned / moved them (on another system) when they are synced | 435 // as the user has pinned / moved them (on another system) when they are synced |
| 433 // random order - including the chrome icon. | 436 // random order - including the chrome icon. |
| 434 TEST_F(ChromeLauncherControllerPerAppTest, | 437 TEST_F(LegacyShelfLayoutChromeLauncherControllerPerAppTest, |
| 435 RestoreDefaultAppsRandomOrderChromeMoved) { | 438 RestoreDefaultAppsRandomOrderChromeMoved) { |
| 436 InitLauncherController(); | 439 InitLauncherController(); |
| 437 | 440 |
| 438 base::ListValue policy_value; | 441 base::ListValue policy_value; |
| 439 InsertPrefValue(&policy_value, 0, extension1_->id()); | 442 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 440 InsertPrefValue(&policy_value, 1, extension2_->id()); | 443 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 441 InsertPrefValue(&policy_value, 2, extension3_->id()); | 444 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 442 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 445 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 443 policy_value.DeepCopy()); | 446 policy_value.DeepCopy()); |
| 444 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, | 447 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 463 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 466 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 464 EXPECT_EQ("App1, Chrome, App2, AppList, ", GetPinnedAppStatus()); | 467 EXPECT_EQ("App1, Chrome, App2, AppList, ", GetPinnedAppStatus()); |
| 465 | 468 |
| 466 // Installing |extension3_| should add it to the launcher - behind the | 469 // Installing |extension3_| should add it to the launcher - behind the |
| 467 // chrome icon, but in first location. | 470 // chrome icon, but in first location. |
| 468 extension_service_->AddExtension(extension3_.get()); | 471 extension_service_->AddExtension(extension3_.get()); |
| 469 EXPECT_EQ("App1, Chrome, App2, App3, AppList, ", GetPinnedAppStatus()); | 472 EXPECT_EQ("App1, Chrome, App2, App3, AppList, ", GetPinnedAppStatus()); |
| 470 } | 473 } |
| 471 | 474 |
| 472 // Check that syncing to a different state does the correct thing. | 475 // Check that syncing to a different state does the correct thing. |
| 473 TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsResyncOrder) { | 476 TEST_F(LegacyShelfLayoutChromeLauncherControllerPerAppTest, |
| 477 RestoreDefaultAppsResyncOrder) { |
| 474 InitLauncherController(); | 478 InitLauncherController(); |
| 475 base::ListValue policy_value; | 479 base::ListValue policy_value; |
| 476 InsertPrefValue(&policy_value, 0, extension1_->id()); | 480 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 477 InsertPrefValue(&policy_value, 1, extension2_->id()); | 481 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 478 InsertPrefValue(&policy_value, 2, extension3_->id()); | 482 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 479 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 483 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 480 policy_value.DeepCopy()); | 484 policy_value.DeepCopy()); |
| 481 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); | 485 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); |
| 482 extension_service_->AddExtension(extension2_.get()); | 486 extension_service_->AddExtension(extension2_.get()); |
| 483 extension_service_->AddExtension(extension1_.get()); | 487 extension_service_->AddExtension(extension1_.get()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 498 InsertPrefValue(&policy_value2, 0, extension2_->id()); | 502 InsertPrefValue(&policy_value2, 0, extension2_->id()); |
| 499 InsertPrefValue(&policy_value2, 1, extension3_->id()); | 503 InsertPrefValue(&policy_value2, 1, extension3_->id()); |
| 500 InsertPrefValue(&policy_value2, 2, extension1_->id()); | 504 InsertPrefValue(&policy_value2, 2, extension1_->id()); |
| 501 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, | 505 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, |
| 502 1); | 506 1); |
| 503 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 507 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 504 policy_value2.DeepCopy()); | 508 policy_value2.DeepCopy()); |
| 505 EXPECT_EQ("App2, Chrome, App3, App1, AppList, ", GetPinnedAppStatus()); | 509 EXPECT_EQ("App2, Chrome, App3, App1, AppList, ", GetPinnedAppStatus()); |
| 506 } | 510 } |
| 507 | 511 |
| 508 TEST_F(AlternateLayoutChromeLauncherControllerPerAppTest, DefaultApps) { | 512 TEST_F(ChromeLauncherControllerPerAppTest, DefaultApps) { |
| 509 InitLauncherController(); | 513 InitLauncherController(); |
| 510 // Model should only contain the browser shortcut and app list items. | 514 // Model should only contain the browser shortcut and app list items. |
| 511 EXPECT_EQ(2, model_->item_count()); | 515 EXPECT_EQ(2, model_->item_count()); |
| 512 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 516 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 513 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 517 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 514 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 518 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 515 | 519 |
| 516 // Installing |extension3_| should add it to the launcher - behind the | 520 // Installing |extension3_| should add it to the launcher - behind the |
| 517 // chrome icon. | 521 // chrome icon. |
| 518 extension_service_->AddExtension(extension3_.get()); | 522 extension_service_->AddExtension(extension3_.get()); |
| 519 EXPECT_EQ("AppList, Chrome, App3, ", GetPinnedAppStatus()); | 523 EXPECT_EQ("AppList, Chrome, App3, ", GetPinnedAppStatus()); |
| 520 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 524 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 521 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 525 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 522 } | 526 } |
| 523 | 527 |
| 524 // Check that the restauration of launcher items is happening in the same order | 528 // Check that the restauration of launcher items is happening in the same order |
| 525 // as the user has pinned them (on another system) when they are synced reverse | 529 // as the user has pinned them (on another system) when they are synced reverse |
| 526 // order. | 530 // order. |
| 527 TEST_F(AlternateLayoutChromeLauncherControllerPerAppTest, | 531 TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsReverseOrder) { |
| 528 RestoreDefaultAppsReverseOrder) { | |
| 529 InitLauncherController(); | 532 InitLauncherController(); |
| 530 | 533 |
| 531 base::ListValue policy_value; | 534 base::ListValue policy_value; |
| 532 InsertPrefValue(&policy_value, 0, extension1_->id()); | 535 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 533 InsertPrefValue(&policy_value, 1, extension2_->id()); | 536 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 534 InsertPrefValue(&policy_value, 2, extension3_->id()); | 537 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 535 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 538 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 536 policy_value.DeepCopy()); | 539 policy_value.DeepCopy()); |
| 537 SetShelfChromeIconIndex(0); | 540 SetShelfChromeIconIndex(0); |
| 538 // Model should only contain the browser shortcut and app list items. | 541 // Model should only contain the browser shortcut and app list items. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 557 | 560 |
| 558 // Installing |extension1_| should add it to the launcher - behind the | 561 // Installing |extension1_| should add it to the launcher - behind the |
| 559 // chrome icon, but in first location. | 562 // chrome icon, but in first location. |
| 560 extension_service_->AddExtension(extension1_.get()); | 563 extension_service_->AddExtension(extension1_.get()); |
| 561 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); | 564 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); |
| 562 } | 565 } |
| 563 | 566 |
| 564 // Check that the restauration of launcher items is happening in the same order | 567 // Check that the restauration of launcher items is happening in the same order |
| 565 // as the user has pinned them (on another system) when they are synced random | 568 // as the user has pinned them (on another system) when they are synced random |
| 566 // order. | 569 // order. |
| 567 TEST_F(AlternateLayoutChromeLauncherControllerPerAppTest, | 570 TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsRandomOrder) { |
| 568 RestoreDefaultAppsRandomOrder) { | |
| 569 InitLauncherController(); | 571 InitLauncherController(); |
| 570 | 572 |
| 571 base::ListValue policy_value; | 573 base::ListValue policy_value; |
| 572 InsertPrefValue(&policy_value, 0, extension1_->id()); | 574 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 573 InsertPrefValue(&policy_value, 1, extension2_->id()); | 575 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 574 InsertPrefValue(&policy_value, 2, extension3_->id()); | 576 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 575 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 577 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 576 policy_value.DeepCopy()); | 578 policy_value.DeepCopy()); |
| 577 SetShelfChromeIconIndex(0); | 579 SetShelfChromeIconIndex(0); |
| 578 // Model should only contain the browser shortcut and app list items. | 580 // Model should only contain the browser shortcut and app list items. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 596 | 598 |
| 597 // Installing |extension3_| should add it to the launcher - behind the | 599 // Installing |extension3_| should add it to the launcher - behind the |
| 598 // chrome icon, but in first location. | 600 // chrome icon, but in first location. |
| 599 extension_service_->AddExtension(extension3_.get()); | 601 extension_service_->AddExtension(extension3_.get()); |
| 600 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); | 602 EXPECT_EQ("AppList, Chrome, App1, App2, App3, ", GetPinnedAppStatus()); |
| 601 } | 603 } |
| 602 | 604 |
| 603 // Check that the restauration of launcher items is happening in the same order | 605 // Check that the restauration of launcher items is happening in the same order |
| 604 // as the user has pinned / moved them (on another system) when they are synced | 606 // as the user has pinned / moved them (on another system) when they are synced |
| 605 // random order - including the chrome icon - using the alternate shelf layout. | 607 // random order - including the chrome icon - using the alternate shelf layout. |
| 606 TEST_F(AlternateLayoutChromeLauncherControllerPerAppTest, | 608 TEST_F(ChromeLauncherControllerPerAppTest, |
| 607 RestoreDefaultAppsRandomOrderChromeMoved) { | 609 RestoreDefaultAppsRandomOrderChromeMoved) { |
| 608 InitLauncherController(); | 610 InitLauncherController(); |
| 609 | 611 |
| 610 base::ListValue policy_value; | 612 base::ListValue policy_value; |
| 611 InsertPrefValue(&policy_value, 0, extension1_->id()); | 613 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 612 InsertPrefValue(&policy_value, 1, extension2_->id()); | 614 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 613 InsertPrefValue(&policy_value, 2, extension3_->id()); | 615 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 614 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 616 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 615 policy_value.DeepCopy()); | 617 policy_value.DeepCopy()); |
| 616 SetShelfChromeIconIndex(1); | 618 SetShelfChromeIconIndex(1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 635 EXPECT_EQ("AppList, App1, Chrome, App2, ", GetPinnedAppStatus()); | 637 EXPECT_EQ("AppList, App1, Chrome, App2, ", GetPinnedAppStatus()); |
| 636 | 638 |
| 637 // Installing |extension3_| should add it to the launcher - behind the | 639 // Installing |extension3_| should add it to the launcher - behind the |
| 638 // chrome icon, but in first location. | 640 // chrome icon, but in first location. |
| 639 extension_service_->AddExtension(extension3_.get()); | 641 extension_service_->AddExtension(extension3_.get()); |
| 640 EXPECT_EQ("AppList, App1, Chrome, App2, App3, ", GetPinnedAppStatus()); | 642 EXPECT_EQ("AppList, App1, Chrome, App2, App3, ", GetPinnedAppStatus()); |
| 641 } | 643 } |
| 642 | 644 |
| 643 // Check that syncing to a different state does the correct thing with the | 645 // Check that syncing to a different state does the correct thing with the |
| 644 // alternate shelf layout. | 646 // alternate shelf layout. |
| 645 TEST_F(AlternateLayoutChromeLauncherControllerPerAppTest, | 647 TEST_F(ChromeLauncherControllerPerAppTest, RestoreDefaultAppsResyncOrder) { |
| 646 RestoreDefaultAppsResyncOrder) { | |
| 647 InitLauncherController(); | 648 InitLauncherController(); |
| 648 base::ListValue policy_value; | 649 base::ListValue policy_value; |
| 649 InsertPrefValue(&policy_value, 0, extension1_->id()); | 650 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 650 InsertPrefValue(&policy_value, 1, extension2_->id()); | 651 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 651 InsertPrefValue(&policy_value, 2, extension3_->id()); | 652 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| 652 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | 653 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 653 policy_value.DeepCopy()); | 654 policy_value.DeepCopy()); |
| 654 // The alternate shelf layout has always one static item at the beginning. | 655 // The alternate shelf layout has always one static item at the beginning. |
| 655 SetShelfChromeIconIndex(0); | 656 SetShelfChromeIconIndex(0); |
| 656 extension_service_->AddExtension(extension2_.get()); | 657 extension_service_->AddExtension(extension2_.get()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 712 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 712 EXPECT_FALSE( | 713 EXPECT_FALSE( |
| 713 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 714 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 714 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 715 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 715 EXPECT_FALSE( | 716 EXPECT_FALSE( |
| 716 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 717 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); |
| 717 | 718 |
| 718 launcher_controller_->LockV1AppWithID(extension1_->id()); | 719 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 719 | 720 |
| 720 EXPECT_EQ(3, model_->item_count()); | 721 EXPECT_EQ(3, model_->item_count()); |
| 721 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 722 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 722 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 723 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 723 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 724 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 724 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 725 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 725 EXPECT_FALSE( | 726 EXPECT_FALSE( |
| 726 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 727 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); |
| 727 | 728 |
| 728 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 729 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 729 | 730 |
| 730 EXPECT_EQ(2, model_->item_count()); | 731 EXPECT_EQ(2, model_->item_count()); |
| 731 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 732 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 732 EXPECT_FALSE( | 733 EXPECT_FALSE( |
| 733 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 734 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 734 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 735 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 735 EXPECT_FALSE( | 736 EXPECT_FALSE( |
| 736 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 737 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); |
| 737 } | 738 } |
| 738 | 739 |
| 739 // Check that multiple locks of an application will be properly handled. | 740 // Check that multiple locks of an application will be properly handled. |
| 740 TEST_F(ChromeLauncherControllerPerAppTest, CheckMukltiLockApps) { | 741 TEST_F(ChromeLauncherControllerPerAppTest, CheckMultiLockApps) { |
| 741 InitLauncherController(); | 742 InitLauncherController(); |
| 742 // Model should only contain the browser shortcut and app list items. | 743 // Model should only contain the browser shortcut and app list items. |
| 743 EXPECT_EQ(2, model_->item_count()); | 744 EXPECT_EQ(2, model_->item_count()); |
| 744 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 745 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 745 EXPECT_FALSE( | 746 EXPECT_FALSE( |
| 746 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 747 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 747 | 748 |
| 748 for (int i = 0; i < 2; i++) { | 749 for (int i = 0; i < 2; i++) { |
| 749 launcher_controller_->LockV1AppWithID(extension1_->id()); | 750 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 750 | 751 |
| 751 EXPECT_EQ(3, model_->item_count()); | 752 EXPECT_EQ(3, model_->item_count()); |
| 752 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 753 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 753 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 754 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 754 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher( | 755 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher( |
| 755 extension1_->id())); | 756 extension1_->id())); |
| 756 } | 757 } |
| 757 | 758 |
| 758 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 759 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 759 | 760 |
| 760 EXPECT_EQ(3, model_->item_count()); | 761 EXPECT_EQ(3, model_->item_count()); |
| 761 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 762 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 762 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 763 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 763 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 764 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 764 | 765 |
| 765 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 766 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 766 | 767 |
| 767 EXPECT_EQ(2, model_->item_count()); | 768 EXPECT_EQ(2, model_->item_count()); |
| 768 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 769 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 769 EXPECT_FALSE( | 770 EXPECT_FALSE( |
| 770 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 771 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 771 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 772 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 772 EXPECT_FALSE( | 773 EXPECT_FALSE( |
| 773 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 774 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 774 } | 775 } |
| 775 | 776 |
| 776 // Check that already pinned items are not effected by locks. | 777 // Check that already pinned items are not effected by locks. |
| 777 TEST_F(ChromeLauncherControllerPerAppTest, CheckAlreadyPinnedLockApps) { | 778 TEST_F(ChromeLauncherControllerPerAppTest, CheckAlreadyPinnedLockApps) { |
| 778 InitLauncherController(); | 779 InitLauncherController(); |
| 779 // Model should only contain the browser shortcut and app list items. | 780 // Model should only contain the browser shortcut and app list items. |
| 780 EXPECT_EQ(2, model_->item_count()); | 781 EXPECT_EQ(2, model_->item_count()); |
| 781 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 782 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 782 EXPECT_FALSE( | 783 EXPECT_FALSE( |
| 783 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 784 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 784 | 785 |
| 785 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 786 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 786 launcher_controller_->PinAppWithID(extension1_->id()); | 787 launcher_controller_->PinAppWithID(extension1_->id()); |
| 787 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 788 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 788 | 789 |
| 789 EXPECT_EQ(3, model_->item_count()); | 790 EXPECT_EQ(3, model_->item_count()); |
| 790 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 791 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 791 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 792 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 792 EXPECT_FALSE( | 793 EXPECT_FALSE( |
| 793 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 794 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 794 | 795 |
| 795 launcher_controller_->LockV1AppWithID(extension1_->id()); | 796 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 796 | 797 |
| 797 EXPECT_EQ(3, model_->item_count()); | 798 EXPECT_EQ(3, model_->item_count()); |
| 798 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 799 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 799 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 800 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 800 EXPECT_FALSE( | 801 EXPECT_FALSE( |
| 801 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 802 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 802 | 803 |
| 803 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 804 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 804 | 805 |
| 805 EXPECT_EQ(3, model_->item_count()); | 806 EXPECT_EQ(3, model_->item_count()); |
| 806 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 807 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 807 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 808 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 808 EXPECT_FALSE( | 809 EXPECT_FALSE( |
| 809 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 810 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 810 | 811 |
| 811 launcher_controller_->UnpinAppsWithID(extension1_->id()); | 812 launcher_controller_->UnpinAppsWithID(extension1_->id()); |
| 812 | 813 |
| 813 EXPECT_EQ(2, model_->item_count()); | 814 EXPECT_EQ(2, model_->item_count()); |
| 814 } | 815 } |
| 815 | 816 |
| 816 // Check that already pinned items which get locked stay after unpinning. | 817 // Check that already pinned items which get locked stay after unpinning. |
| 817 TEST_F(ChromeLauncherControllerPerAppTest, CheckPinnedAppsStayAfterUnlock) { | 818 TEST_F(ChromeLauncherControllerPerAppTest, CheckPinnedAppsStayAfterUnlock) { |
| 818 InitLauncherController(); | 819 InitLauncherController(); |
| 819 // Model should only contain the browser shortcut and app list items. | 820 // Model should only contain the browser shortcut and app list items. |
| 820 EXPECT_EQ(2, model_->item_count()); | 821 EXPECT_EQ(2, model_->item_count()); |
| 821 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 822 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 822 EXPECT_FALSE( | 823 EXPECT_FALSE( |
| 823 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 824 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 824 | 825 |
| 825 launcher_controller_->PinAppWithID(extension1_->id()); | 826 launcher_controller_->PinAppWithID(extension1_->id()); |
| 826 | 827 |
| 827 EXPECT_EQ(3, model_->item_count()); | 828 EXPECT_EQ(3, model_->item_count()); |
| 828 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 829 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 829 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 830 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 830 EXPECT_FALSE( | 831 EXPECT_FALSE( |
| 831 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 832 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 832 | 833 |
| 833 launcher_controller_->LockV1AppWithID(extension1_->id()); | 834 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 834 | 835 |
| 835 EXPECT_EQ(3, model_->item_count()); | 836 EXPECT_EQ(3, model_->item_count()); |
| 836 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 837 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 837 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 838 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 838 EXPECT_FALSE( | 839 EXPECT_FALSE( |
| 839 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 840 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 840 | 841 |
| 841 launcher_controller_->UnpinAppsWithID(extension1_->id()); | 842 launcher_controller_->UnpinAppsWithID(extension1_->id()); |
| 842 | 843 |
| 843 EXPECT_EQ(3, model_->item_count()); | 844 EXPECT_EQ(3, model_->item_count()); |
| 844 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 845 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 845 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 846 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 846 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 847 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 847 | 848 |
| 848 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 849 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 849 | 850 |
| 850 EXPECT_EQ(2, model_->item_count()); | 851 EXPECT_EQ(2, model_->item_count()); |
| 851 } | 852 } |
| 852 | 853 |
| 853 // Check that lock -> pin -> unlock -> unpin does properly transition. | 854 // Check that lock -> pin -> unlock -> unpin does properly transition. |
| 854 TEST_F(ChromeLauncherControllerPerAppTest, CheckLockPinUnlockUnpin) { | 855 TEST_F(ChromeLauncherControllerPerAppTest, CheckLockPinUnlockUnpin) { |
| 855 InitLauncherController(); | 856 InitLauncherController(); |
| 856 // Model should only contain the browser shortcut and app list items. | 857 // Model should only contain the browser shortcut and app list items. |
| 857 EXPECT_EQ(2, model_->item_count()); | 858 EXPECT_EQ(2, model_->item_count()); |
| 858 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 859 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 859 EXPECT_FALSE( | 860 EXPECT_FALSE( |
| 860 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 861 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 861 | 862 |
| 862 launcher_controller_->LockV1AppWithID(extension1_->id()); | 863 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 863 | 864 |
| 864 EXPECT_EQ(3, model_->item_count()); | 865 EXPECT_EQ(3, model_->item_count()); |
| 865 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[1].type); | 866 EXPECT_EQ(ash::TYPE_WINDOWED_APP, model_->items()[2].type); |
| 866 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 867 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 867 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 868 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 868 | 869 |
| 869 launcher_controller_->PinAppWithID(extension1_->id()); | 870 launcher_controller_->PinAppWithID(extension1_->id()); |
| 870 | 871 |
| 871 EXPECT_EQ(3, model_->item_count()); | 872 EXPECT_EQ(3, model_->item_count()); |
| 872 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 873 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 873 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 874 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 874 EXPECT_FALSE( | 875 EXPECT_FALSE( |
| 875 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 876 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 876 | 877 |
| 877 launcher_controller_->UnlockV1AppWithID(extension1_->id()); | 878 launcher_controller_->UnlockV1AppWithID(extension1_->id()); |
| 878 | 879 |
| 879 EXPECT_EQ(3, model_->item_count()); | 880 EXPECT_EQ(3, model_->item_count()); |
| 880 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 881 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 881 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 882 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 882 EXPECT_FALSE( | 883 EXPECT_FALSE( |
| 883 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 884 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 884 | 885 |
| 885 launcher_controller_->UnpinAppsWithID(extension1_->id()); | 886 launcher_controller_->UnpinAppsWithID(extension1_->id()); |
| 886 | 887 |
| 887 EXPECT_EQ(2, model_->item_count()); | 888 EXPECT_EQ(2, model_->item_count()); |
| 888 } | 889 } |
| 889 | 890 |
| 890 TEST_F(ChromeLauncherControllerPerAppTest, Policy) { | 891 TEST_F(ChromeLauncherControllerPerAppTest, Policy) { |
| 891 extension_service_->AddExtension(extension1_.get()); | 892 extension_service_->AddExtension(extension1_.get()); |
| 892 extension_service_->AddExtension(extension3_.get()); | 893 extension_service_->AddExtension(extension3_.get()); |
| 893 | 894 |
| 894 base::ListValue policy_value; | 895 base::ListValue policy_value; |
| 895 InsertPrefValue(&policy_value, 0, extension1_->id()); | 896 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 896 InsertPrefValue(&policy_value, 1, extension2_->id()); | 897 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 897 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, | 898 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, |
| 898 policy_value.DeepCopy()); | 899 policy_value.DeepCopy()); |
| 899 | 900 |
| 900 // Only |extension1_| should get pinned. |extension2_| is specified but not | 901 // Only |extension1_| should get pinned. |extension2_| is specified but not |
| 901 // installed, and |extension3_| is part of the default set, but that shouldn't | 902 // installed, and |extension3_| is part of the default set, but that shouldn't |
| 902 // take effect when the policy override is in place. | 903 // take effect when the policy override is in place. |
| 903 InitLauncherController(); | 904 InitLauncherController(); |
| 904 EXPECT_EQ(3, model_->item_count()); | 905 EXPECT_EQ(3, model_->item_count()); |
| 905 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 906 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 906 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 907 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 907 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 908 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 908 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 909 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 909 | 910 |
| 910 // Installing |extension2_| should add it to the launcher. | 911 // Installing |extension2_| should add it to the launcher. |
| 911 extension_service_->AddExtension(extension2_.get()); | 912 extension_service_->AddExtension(extension2_.get()); |
| 912 EXPECT_EQ(4, model_->item_count()); | 913 EXPECT_EQ(4, model_->item_count()); |
| 913 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | |
| 914 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 914 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 915 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[3].type); |
| 915 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 916 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 916 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 917 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 917 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 918 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 918 | 919 |
| 919 // Removing |extension1_| from the policy should be reflected in the launcher. | 920 // Removing |extension1_| from the policy should be reflected in the launcher. |
| 920 policy_value.Remove(0, NULL); | 921 policy_value.Remove(0, NULL); |
| 921 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, | 922 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, |
| 922 policy_value.DeepCopy()); | 923 policy_value.DeepCopy()); |
| 923 EXPECT_EQ(3, model_->item_count()); | 924 EXPECT_EQ(3, model_->item_count()); |
| 924 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 925 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 925 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 926 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 926 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 927 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 927 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 928 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 928 } | 929 } |
| 929 | 930 |
| 930 TEST_F(ChromeLauncherControllerPerAppTest, UnpinWithUninstall) { | 931 TEST_F(ChromeLauncherControllerPerAppTest, UnpinWithUninstall) { |
| 931 extension_service_->AddExtension(extension3_.get()); | 932 extension_service_->AddExtension(extension3_.get()); |
| 932 extension_service_->AddExtension(extension4_.get()); | 933 extension_service_->AddExtension(extension4_.get()); |
| 933 | 934 |
| 934 InitLauncherController(); | 935 InitLauncherController(); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 ash::LauncherID gmail_id = model_->next_id(); | 1379 ash::LauncherID gmail_id = model_->next_id(); |
| 1379 extension_service_->AddExtension(extension3_.get()); | 1380 extension_service_->AddExtension(extension3_.get()); |
| 1380 EXPECT_EQ(3, model_->item_count()); | 1381 EXPECT_EQ(3, model_->item_count()); |
| 1381 int gmail_index = model_->ItemIndexByID(gmail_id); | 1382 int gmail_index = model_->ItemIndexByID(gmail_id); |
| 1382 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type); | 1383 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type); |
| 1383 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1384 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1384 | 1385 |
| 1385 // The content should not be able to be handled by the app. | 1386 // The content should not be able to be handled by the app. |
| 1386 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); | 1387 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); |
| 1387 } | 1388 } |
| OLD | NEW |