| 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 |
| 11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/launcher/launcher_item_delegate_manager.h" | 12 #include "ash/shelf/shelf_item_delegate_manager.h" |
| 13 #include "ash/shelf/shelf_model.h" | 13 #include "ash/shelf/shelf_model.h" |
| 14 #include "ash/shelf/shelf_model_observer.h" | 14 #include "ash/shelf/shelf_model_observer.h" |
| 15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/test/launcher_item_delegate_manager_test_api.h" | 16 #include "ash/test/shelf_item_delegate_manager_test_api.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
| 21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/values.h" | 23 #include "base/values.h" |
| 24 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
| 25 #include "chrome/browser/extensions/test_extension_system.h" | 25 #include "chrome/browser/extensions/test_extension_system.h" |
| 26 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" | 26 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 virtual void Close() OVERRIDE {} | 234 virtual void Close() OVERRIDE {} |
| 235 virtual bool ItemSelected(const ui::Event& event) OVERRIDE { return false; } | 235 virtual bool ItemSelected(const ui::Event& event) OVERRIDE { return false; } |
| 236 virtual string16 GetTitle() OVERRIDE { return string16(); } | 236 virtual string16 GetTitle() OVERRIDE { return string16(); } |
| 237 virtual ChromeLauncherAppMenuItems GetApplicationList( | 237 virtual ChromeLauncherAppMenuItems GetApplicationList( |
| 238 int event_flags) OVERRIDE { | 238 int event_flags) OVERRIDE { |
| 239 ChromeLauncherAppMenuItems items; | 239 ChromeLauncherAppMenuItems items; |
| 240 items.push_back(new ChromeLauncherAppMenuItem(string16(), NULL, false)); | 240 items.push_back(new ChromeLauncherAppMenuItem(string16(), NULL, false)); |
| 241 items.push_back(new ChromeLauncherAppMenuItem(string16(), NULL, false)); | 241 items.push_back(new ChromeLauncherAppMenuItem(string16(), NULL, false)); |
| 242 return items.Pass(); | 242 return items.Pass(); |
| 243 } | 243 } |
| 244 virtual ui::MenuModel* CreateContextMenu( | 244 virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) OVERRIDE { |
| 245 aura::Window* root_window) OVERRIDE { return NULL; } | 245 return NULL; |
| 246 virtual ash::LauncherMenuModel* CreateApplicationMenu( | 246 } |
| 247 int event_flags) OVERRIDE { return NULL; } | 247 virtual ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) OVERRIDE { |
| 248 return NULL; |
| 249 } |
| 248 virtual bool IsDraggable() OVERRIDE { return false; } | 250 virtual bool IsDraggable() OVERRIDE { return false; } |
| 249 virtual bool ShouldShowTooltip() OVERRIDE { return false; } | 251 virtual bool ShouldShowTooltip() OVERRIDE { return false; } |
| 250 | 252 |
| 251 private: | 253 private: |
| 252 | 254 |
| 253 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); | 255 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); |
| 254 }; | 256 }; |
| 255 | 257 |
| 256 } // namespace | 258 } // namespace |
| 257 | 259 |
| 258 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { | 260 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { |
| 259 protected: | 261 protected: |
| 260 ChromeLauncherControllerTest() : test_controller_(NULL), | 262 ChromeLauncherControllerTest() : test_controller_(NULL), |
| 261 extension_service_(NULL) { | 263 extension_service_(NULL) { |
| 262 SetHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH); | 264 SetHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH); |
| 263 } | 265 } |
| 264 | 266 |
| 265 virtual ~ChromeLauncherControllerTest() { | 267 virtual ~ChromeLauncherControllerTest() { |
| 266 } | 268 } |
| 267 | 269 |
| 268 virtual void SetUp() OVERRIDE { | 270 virtual void SetUp() OVERRIDE { |
| 269 BrowserWithTestWindowTest::SetUp(); | 271 BrowserWithTestWindowTest::SetUp(); |
| 270 | 272 |
| 271 model_.reset(new ash::ShelfModel); | 273 model_.reset(new ash::ShelfModel); |
| 272 model_observer_.reset(new TestShelfModelObserver); | 274 model_observer_.reset(new TestShelfModelObserver); |
| 273 model_->AddObserver(model_observer_.get()); | 275 model_->AddObserver(model_observer_.get()); |
| 274 | 276 |
| 275 if (ash::Shell::HasInstance()) { | 277 if (ash::Shell::HasInstance()) { |
| 276 item_delegate_manager_ = | 278 item_delegate_manager_ = |
| 277 ash::Shell::GetInstance()->launcher_item_delegate_manager(); | 279 ash::Shell::GetInstance()->shelf_item_delegate_manager(); |
| 278 } else { | 280 } else { |
| 279 item_delegate_manager_ = | 281 item_delegate_manager_ = |
| 280 new ash::LauncherItemDelegateManager(model_.get()); | 282 new ash::ShelfItemDelegateManager(model_.get()); |
| 281 } | 283 } |
| 282 | 284 |
| 283 DictionaryValue manifest; | 285 DictionaryValue manifest; |
| 284 manifest.SetString(extensions::manifest_keys::kName, | 286 manifest.SetString(extensions::manifest_keys::kName, |
| 285 "launcher controller test extension"); | 287 "launcher controller test extension"); |
| 286 manifest.SetString(extensions::manifest_keys::kVersion, "1"); | 288 manifest.SetString(extensions::manifest_keys::kVersion, "1"); |
| 287 manifest.SetString(extensions::manifest_keys::kDescription, | 289 manifest.SetString(extensions::manifest_keys::kDescription, |
| 288 "for testing pinned apps"); | 290 "for testing pinned apps"); |
| 289 | 291 |
| 290 extensions::TestExtensionSystem* extension_system( | 292 extensions::TestExtensionSystem* extension_system( |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 ash::LauncherItem app_list; | 421 ash::LauncherItem app_list; |
| 420 app_list.type = ash::TYPE_APP_LIST; | 422 app_list.type = ash::TYPE_APP_LIST; |
| 421 model_->Add(app_list); | 423 model_->Add(app_list); |
| 422 } | 424 } |
| 423 | 425 |
| 424 void InitLauncherController() { | 426 void InitLauncherController() { |
| 425 AddAppListLauncherItem(); | 427 AddAppListLauncherItem(); |
| 426 launcher_controller_.reset( | 428 launcher_controller_.reset( |
| 427 new ChromeLauncherController(profile(), model_.get())); | 429 new ChromeLauncherController(profile(), model_.get())); |
| 428 if (!ash::Shell::HasInstance()) | 430 if (!ash::Shell::HasInstance()) |
| 429 SetLauncherItemDelegateManager(item_delegate_manager_); | 431 SetShelfItemDelegateManager(item_delegate_manager_); |
| 430 launcher_controller_->Init(); | 432 launcher_controller_->Init(); |
| 431 } | 433 } |
| 432 | 434 |
| 433 void InitLauncherControllerWithBrowser() { | 435 void InitLauncherControllerWithBrowser() { |
| 434 chrome::NewTab(browser()); | 436 chrome::NewTab(browser()); |
| 435 BrowserList::SetLastActive(browser()); | 437 BrowserList::SetLastActive(browser()); |
| 436 InitLauncherController(); | 438 InitLauncherController(); |
| 437 } | 439 } |
| 438 | 440 |
| 439 void SetAppIconLoader(extensions::AppIconLoader* loader) { | 441 void SetAppIconLoader(extensions::AppIconLoader* loader) { |
| 440 launcher_controller_->SetAppIconLoaderForTest(loader); | 442 launcher_controller_->SetAppIconLoaderForTest(loader); |
| 441 } | 443 } |
| 442 | 444 |
| 443 void SetAppTabHelper(ChromeLauncherController::AppTabHelper* helper) { | 445 void SetAppTabHelper(ChromeLauncherController::AppTabHelper* helper) { |
| 444 launcher_controller_->SetAppTabHelperForTest(helper); | 446 launcher_controller_->SetAppTabHelperForTest(helper); |
| 445 } | 447 } |
| 446 | 448 |
| 447 void SetLauncherItemDelegateManager( | 449 void SetShelfItemDelegateManager(ash::ShelfItemDelegateManager* manager) { |
| 448 ash::LauncherItemDelegateManager* manager) { | 450 launcher_controller_->SetShelfItemDelegateManagerForTest(manager); |
| 449 launcher_controller_->SetLauncherItemDelegateManagerForTest(manager); | |
| 450 } | 451 } |
| 451 | 452 |
| 452 void InsertPrefValue(base::ListValue* pref_value, | 453 void InsertPrefValue(base::ListValue* pref_value, |
| 453 int index, | 454 int index, |
| 454 const std::string& extension_id) { | 455 const std::string& extension_id) { |
| 455 base::DictionaryValue* entry = new DictionaryValue(); | 456 base::DictionaryValue* entry = new DictionaryValue(); |
| 456 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id); | 457 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id); |
| 457 pref_value->Insert(index, entry); | 458 pref_value->Insert(index, entry); |
| 458 } | 459 } |
| 459 | 460 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 scoped_refptr<Extension> extension8_; | 589 scoped_refptr<Extension> extension8_; |
| 589 scoped_ptr<ChromeLauncherController> launcher_controller_; | 590 scoped_ptr<ChromeLauncherController> launcher_controller_; |
| 590 scoped_ptr<TestShelfModelObserver> model_observer_; | 591 scoped_ptr<TestShelfModelObserver> model_observer_; |
| 591 scoped_ptr<ash::ShelfModel> model_; | 592 scoped_ptr<ash::ShelfModel> model_; |
| 592 | 593 |
| 593 // |item_delegate_manager_| owns |test_controller_|. | 594 // |item_delegate_manager_| owns |test_controller_|. |
| 594 LauncherItemController* test_controller_; | 595 LauncherItemController* test_controller_; |
| 595 | 596 |
| 596 ExtensionService* extension_service_; | 597 ExtensionService* extension_service_; |
| 597 | 598 |
| 598 ash::LauncherItemDelegateManager* item_delegate_manager_; | 599 ash::ShelfItemDelegateManager* item_delegate_manager_; |
| 599 | 600 |
| 600 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); | 601 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); |
| 601 }; | 602 }; |
| 602 | 603 |
| 603 // The testing framework to test the legacy shelf layout. | 604 // The testing framework to test the legacy shelf layout. |
| 604 class LegacyShelfLayoutChromeLauncherControllerTest | 605 class LegacyShelfLayoutChromeLauncherControllerTest |
| 605 : public ChromeLauncherControllerTest { | 606 : public ChromeLauncherControllerTest { |
| 606 protected: | 607 protected: |
| 607 LegacyShelfLayoutChromeLauncherControllerTest() { | 608 LegacyShelfLayoutChromeLauncherControllerTest() { |
| 608 } | 609 } |
| (...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2068 EXPECT_FALSE(items[0]->IsEnabled()); | 2069 EXPECT_FALSE(items[0]->IsEnabled()); |
| 2069 for (size_t i = 0; i < expected_items; i++) { | 2070 for (size_t i = 0; i < expected_items; i++) { |
| 2070 EXPECT_EQ(title[i], items[1 + i]->title()); | 2071 EXPECT_EQ(title[i], items[1 + i]->title()); |
| 2071 // Check that the first real item has a leading separator. | 2072 // Check that the first real item has a leading separator. |
| 2072 if (i == 1) | 2073 if (i == 1) |
| 2073 EXPECT_TRUE(items[i]->HasLeadingSeparator()); | 2074 EXPECT_TRUE(items[i]->HasLeadingSeparator()); |
| 2074 else | 2075 else |
| 2075 EXPECT_FALSE(items[i]->HasLeadingSeparator()); | 2076 EXPECT_FALSE(items[i]->HasLeadingSeparator()); |
| 2076 } | 2077 } |
| 2077 | 2078 |
| 2078 scoped_ptr<ash::LauncherMenuModel> menu( | 2079 scoped_ptr<ash::ShelfMenuModel> menu(new LauncherApplicationMenuItemModel( |
| 2079 new LauncherApplicationMenuItemModel( | 2080 controller->GetApplicationList(item, 0))); |
| 2080 controller->GetApplicationList(item, 0))); | |
| 2081 // The first element in the menu is a spacing separator. On some systems | 2081 // The first element in the menu is a spacing separator. On some systems |
| 2082 // (e.g. Windows) such things do not exist. As such we check the existence | 2082 // (e.g. Windows) such things do not exist. As such we check the existence |
| 2083 // and adjust dynamically. | 2083 // and adjust dynamically. |
| 2084 int first_item = menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR ? 1 : 0; | 2084 int first_item = menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR ? 1 : 0; |
| 2085 int expected_menu_items = first_item + | 2085 int expected_menu_items = first_item + |
| 2086 (expected_items ? (expected_items + 3) : 2); | 2086 (expected_items ? (expected_items + 3) : 2); |
| 2087 EXPECT_EQ(expected_menu_items, menu->GetItemCount()); | 2087 EXPECT_EQ(expected_menu_items, menu->GetItemCount()); |
| 2088 EXPECT_FALSE(menu->IsEnabledAt(first_item)); | 2088 EXPECT_FALSE(menu->IsEnabledAt(first_item)); |
| 2089 if (expected_items) { | 2089 if (expected_items) { |
| 2090 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR, | 2090 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR, |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2415 ash::LauncherItem item_gmail; | 2415 ash::LauncherItem item_gmail; |
| 2416 item_gmail.type = ash::TYPE_APP_SHORTCUT; | 2416 item_gmail.type = ash::TYPE_APP_SHORTCUT; |
| 2417 item_gmail.id = gmail_id; | 2417 item_gmail.id = gmail_id; |
| 2418 string16 two_menu_items[] = {title1, title2}; | 2418 string16 two_menu_items[] = {title1, title2}; |
| 2419 EXPECT_TRUE(CheckMenuCreation( | 2419 EXPECT_TRUE(CheckMenuCreation( |
| 2420 launcher_controller_.get(), item_gmail, 2, two_menu_items, false)); | 2420 launcher_controller_.get(), item_gmail, 2, two_menu_items, false)); |
| 2421 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 2421 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 2422 // Execute the second item in the list (which shouldn't do anything since that | 2422 // Execute the second item in the list (which shouldn't do anything since that |
| 2423 // item is per definition already the active tab). | 2423 // item is per definition already the active tab). |
| 2424 { | 2424 { |
| 2425 scoped_ptr<ash::LauncherMenuModel> menu( | 2425 scoped_ptr<ash::ShelfMenuModel> menu(new LauncherApplicationMenuItemModel( |
| 2426 new LauncherApplicationMenuItemModel( | 2426 launcher_controller_->GetApplicationList(item_gmail, 0))); |
| 2427 launcher_controller_->GetApplicationList(item_gmail, 0))); | |
| 2428 // The first element in the menu is a spacing separator. On some systems | 2427 // The first element in the menu is a spacing separator. On some systems |
| 2429 // (e.g. Windows) such things do not exist. As such we check the existence | 2428 // (e.g. Windows) such things do not exist. As such we check the existence |
| 2430 // and adjust dynamically. | 2429 // and adjust dynamically. |
| 2431 int first_item = | 2430 int first_item = |
| 2432 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; | 2431 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; |
| 2433 menu->ActivatedAt(first_item + 3); | 2432 menu->ActivatedAt(first_item + 3); |
| 2434 } | 2433 } |
| 2435 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); | 2434 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); |
| 2436 | 2435 |
| 2437 // Execute the first item. | 2436 // Execute the first item. |
| 2438 { | 2437 { |
| 2439 scoped_ptr<ash::LauncherMenuModel> menu( | 2438 scoped_ptr<ash::ShelfMenuModel> menu(new LauncherApplicationMenuItemModel( |
| 2440 new LauncherApplicationMenuItemModel( | 2439 launcher_controller_->GetApplicationList(item_gmail, 0))); |
| 2441 launcher_controller_->GetApplicationList(item_gmail, 0))); | |
| 2442 int first_item = | 2440 int first_item = |
| 2443 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; | 2441 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; |
| 2444 menu->ActivatedAt(first_item + 2); | 2442 menu->ActivatedAt(first_item + 2); |
| 2445 } | 2443 } |
| 2446 // Now the active tab should be the second item. | 2444 // Now the active tab should be the second item. |
| 2447 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 2445 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
| 2448 } | 2446 } |
| 2449 | 2447 |
| 2450 // Checks that the generated menu list properly deletes items. | 2448 // Checks that the generated menu list properly deletes items. |
| 2451 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) { | 2449 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2633 model_->Move(1, 3); | 2631 model_->Move(1, 3); |
| 2634 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); | 2632 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 2635 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 2633 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); |
| 2636 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 2634 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 2637 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); | 2635 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); |
| 2638 | 2636 |
| 2639 launcher_controller_.reset(); | 2637 launcher_controller_.reset(); |
| 2640 if (!ash::Shell::HasInstance()) { | 2638 if (!ash::Shell::HasInstance()) { |
| 2641 delete item_delegate_manager_; | 2639 delete item_delegate_manager_; |
| 2642 } else { | 2640 } else { |
| 2643 // Clear already registered LauncherItemDelegate. | 2641 // Clear already registered ShelfItemDelegate. |
| 2644 ash::test::LauncherItemDelegateManagerTestAPI test(item_delegate_manager_); | 2642 ash::test::ShelfItemDelegateManagerTestAPI test(item_delegate_manager_); |
| 2645 test.RemoveAllLauncherItemDelegateForTest(); | 2643 test.RemoveAllShelfItemDelegateForTest(); |
| 2646 } | 2644 } |
| 2647 model_.reset(new ash::ShelfModel); | 2645 model_.reset(new ash::ShelfModel); |
| 2648 | 2646 |
| 2649 AddAppListLauncherItem(); | 2647 AddAppListLauncherItem(); |
| 2650 launcher_controller_.reset( | 2648 launcher_controller_.reset( |
| 2651 ChromeLauncherController::CreateInstance(profile(), model_.get())); | 2649 ChromeLauncherController::CreateInstance(profile(), model_.get())); |
| 2652 app_tab_helper = new TestAppTabHelperImpl; | 2650 app_tab_helper = new TestAppTabHelperImpl; |
| 2653 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 2651 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 2654 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); | 2652 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); |
| 2655 SetAppTabHelper(app_tab_helper); | 2653 SetAppTabHelper(app_tab_helper); |
| 2656 if (!ash::Shell::HasInstance()) { | 2654 if (!ash::Shell::HasInstance()) { |
| 2657 item_delegate_manager_ = | 2655 item_delegate_manager_ = new ash::ShelfItemDelegateManager(model_.get()); |
| 2658 new ash::LauncherItemDelegateManager(model_.get()); | 2656 SetShelfItemDelegateManager(item_delegate_manager_); |
| 2659 SetLauncherItemDelegateManager(item_delegate_manager_); | |
| 2660 } | 2657 } |
| 2661 launcher_controller_->Init(); | 2658 launcher_controller_->Init(); |
| 2662 | 2659 |
| 2663 // Check LauncherItems are restored after resetting ChromeLauncherController. | 2660 // Check LauncherItems are restored after resetting ChromeLauncherController. |
| 2664 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); | 2661 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); |
| 2665 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); | 2662 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); |
| 2666 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 2663 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 2667 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); | 2664 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); |
| 2668 } | 2665 } |
| 2669 | 2666 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2689 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2686 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2690 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2687 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 2691 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2688 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 2692 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2689 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 2693 EXPECT_EQ(initial_size + 1, model_->items().size()); | 2690 EXPECT_EQ(initial_size + 1, model_->items().size()); |
| 2694 | 2691 |
| 2695 launcher_controller_.reset(); | 2692 launcher_controller_.reset(); |
| 2696 if (!ash::Shell::HasInstance()) { | 2693 if (!ash::Shell::HasInstance()) { |
| 2697 delete item_delegate_manager_; | 2694 delete item_delegate_manager_; |
| 2698 } else { | 2695 } else { |
| 2699 // Clear already registered LauncherItemDelegate. | 2696 // Clear already registered ShelfItemDelegate. |
| 2700 ash::test::LauncherItemDelegateManagerTestAPI test(item_delegate_manager_); | 2697 ash::test::ShelfItemDelegateManagerTestAPI test(item_delegate_manager_); |
| 2701 test.RemoveAllLauncherItemDelegateForTest(); | 2698 test.RemoveAllShelfItemDelegateForTest(); |
| 2702 } | 2699 } |
| 2703 model_.reset(new ash::ShelfModel); | 2700 model_.reset(new ash::ShelfModel); |
| 2704 | 2701 |
| 2705 AddAppListLauncherItem(); | 2702 AddAppListLauncherItem(); |
| 2706 launcher_controller_.reset( | 2703 launcher_controller_.reset( |
| 2707 ChromeLauncherController::CreateInstance(profile(), model_.get())); | 2704 ChromeLauncherController::CreateInstance(profile(), model_.get())); |
| 2708 app_tab_helper = new TestAppTabHelperImpl; | 2705 app_tab_helper = new TestAppTabHelperImpl; |
| 2709 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 2706 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 2710 SetAppTabHelper(app_tab_helper); | 2707 SetAppTabHelper(app_tab_helper); |
| 2711 app_icon_loader = new TestAppIconLoaderImpl; | 2708 app_icon_loader = new TestAppIconLoaderImpl; |
| 2712 SetAppIconLoader(app_icon_loader); | 2709 SetAppIconLoader(app_icon_loader); |
| 2713 if (!ash::Shell::HasInstance()) { | 2710 if (!ash::Shell::HasInstance()) { |
| 2714 item_delegate_manager_ = | 2711 item_delegate_manager_ = new ash::ShelfItemDelegateManager(model_.get()); |
| 2715 new ash::LauncherItemDelegateManager(model_.get()); | 2712 SetShelfItemDelegateManager(item_delegate_manager_); |
| 2716 SetLauncherItemDelegateManager(item_delegate_manager_); | |
| 2717 } | 2713 } |
| 2718 launcher_controller_->Init(); | 2714 launcher_controller_->Init(); |
| 2719 | 2715 |
| 2720 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2716 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2721 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2717 ASSERT_EQ(initial_size + 1, model_->items().size()); |
| 2722 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2718 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 2723 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2719 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 2724 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2720 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 2725 | 2721 |
| 2726 launcher_controller_->UnpinAppWithID("1"); | 2722 launcher_controller_->UnpinAppWithID("1"); |
| 2727 ASSERT_EQ(initial_size, model_->items().size()); | 2723 ASSERT_EQ(initial_size, model_->items().size()); |
| 2728 } | 2724 } |
| OLD | NEW |