| 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/shelf/shelf_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/shelf_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" |
| 27 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" |
| 27 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" | 28 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" |
| 28 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 29 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 29 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h
" | |
| 30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 31 #include "chrome/browser/ui/browser_commands.h" | 31 #include "chrome/browser/ui/browser_commands.h" |
| 32 #include "chrome/browser/ui/browser_finder.h" | 32 #include "chrome/browser/ui/browser_finder.h" |
| 33 #include "chrome/browser/ui/browser_list.h" | 33 #include "chrome/browser/ui/browser_list.h" |
| 34 #include "chrome/browser/ui/browser_tabstrip.h" | 34 #include "chrome/browser/ui/browser_tabstrip.h" |
| 35 #include "chrome/browser/ui/host_desktop.h" | 35 #include "chrome/browser/ui/host_desktop.h" |
| 36 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 36 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 37 #include "chrome/common/extensions/extension_constants.h" | 37 #include "chrome/common/extensions/extension_constants.h" |
| 38 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/test/base/browser_with_test_window_test.h" | 39 #include "chrome/test/base/browser_with_test_window_test.h" |
| 40 #include "chrome/test/base/testing_pref_service_syncable.h" | 40 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 41 #include "chrome/test/base/testing_profile.h" | 41 #include "chrome/test/base/testing_profile.h" |
| 42 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
| 43 #include "extensions/common/extension.h" | 43 #include "extensions/common/extension.h" |
| 44 #include "extensions/common/manifest_constants.h" | 44 #include "extensions/common/manifest_constants.h" |
| 45 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
| 46 #include "ui/base/models/menu_model.h" | 46 #include "ui/base/models/menu_model.h" |
| 47 | 47 |
| 48 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
| 49 #include "apps/app_window_contents.h" | 49 #include "apps/app_window_contents.h" |
| 50 #include "apps/app_window_registry.h" | 50 #include "apps/app_window_registry.h" |
| 51 #include "apps/ui/native_app_window.h" | 51 #include "apps/ui/native_app_window.h" |
| 52 #include "ash/test/test_session_state_delegate.h" | 52 #include "ash/test/test_session_state_delegate.h" |
| 53 #include "ash/test/test_shell_delegate.h" | 53 #include "ash/test/test_shell_delegate.h" |
| 54 #include "chrome/browser/chromeos/login/fake_user_manager.h" | 54 #include "chrome/browser/chromeos/login/fake_user_manager.h" |
| 55 #include "chrome/browser/ui/apps/chrome_shell_window_delegate.h" | 55 #include "chrome/browser/ui/apps/chrome_shell_window_delegate.h" |
| 56 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" |
| 56 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" | 57 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" |
| 57 #include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h" | |
| 58 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 58 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 59 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 59 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 60 #include "chrome/common/chrome_constants.h" | 60 #include "chrome/common/chrome_constants.h" |
| 61 #include "chrome/common/chrome_switches.h" | 61 #include "chrome/common/chrome_switches.h" |
| 62 #include "chrome/test/base/testing_browser_process.h" | 62 #include "chrome/test/base/testing_browser_process.h" |
| 63 #include "chrome/test/base/testing_profile_manager.h" | 63 #include "chrome/test/base/testing_profile_manager.h" |
| 64 #include "content/public/browser/web_contents_observer.h" | 64 #include "content/public/browser/web_contents_observer.h" |
| 65 #include "content/public/test/test_utils.h" | 65 #include "content/public/test/test_utils.h" |
| 66 #include "ui/aura/window.h" | 66 #include "ui/aura/window.h" |
| 67 #include "ui/views/test/test_views_delegate.h" | 67 #include "ui/views/test/test_views_delegate.h" |
| (...skipping 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 TEST_F(ChromeLauncherControllerTest, AppPanels) { | 2562 TEST_F(ChromeLauncherControllerTest, AppPanels) { |
| 2563 InitLauncherControllerWithBrowser(); | 2563 InitLauncherControllerWithBrowser(); |
| 2564 // App list and Browser shortcut ShelfItems are added. | 2564 // App list and Browser shortcut ShelfItems are added. |
| 2565 EXPECT_EQ(2, model_observer_->added()); | 2565 EXPECT_EQ(2, model_observer_->added()); |
| 2566 | 2566 |
| 2567 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); | 2567 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); |
| 2568 SetAppIconLoader(app_icon_loader); | 2568 SetAppIconLoader(app_icon_loader); |
| 2569 | 2569 |
| 2570 // Test adding an app panel | 2570 // Test adding an app panel |
| 2571 std::string app_id = extension1_->id(); | 2571 std::string app_id = extension1_->id(); |
| 2572 ShellWindowLauncherItemController* app_panel_controller = | 2572 AppWindowLauncherItemController* app_panel_controller = |
| 2573 new ShellWindowLauncherItemController( | 2573 new AppWindowLauncherItemController( |
| 2574 LauncherItemController::TYPE_APP_PANEL, | 2574 LauncherItemController::TYPE_APP_PANEL, |
| 2575 "id", | 2575 "id", |
| 2576 app_id, | 2576 app_id, |
| 2577 launcher_controller_.get()); | 2577 launcher_controller_.get()); |
| 2578 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( | 2578 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( |
| 2579 app_panel_controller, app_id, ash::STATUS_RUNNING); | 2579 app_panel_controller, app_id, ash::STATUS_RUNNING); |
| 2580 int panel_index = model_observer_->last_index(); | 2580 int panel_index = model_observer_->last_index(); |
| 2581 EXPECT_EQ(3, model_observer_->added()); | 2581 EXPECT_EQ(3, model_observer_->added()); |
| 2582 EXPECT_EQ(0, model_observer_->changed()); | 2582 EXPECT_EQ(0, model_observer_->changed()); |
| 2583 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2583 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2584 model_observer_->clear_counts(); | 2584 model_observer_->clear_counts(); |
| 2585 | 2585 |
| 2586 // App panels should have a separate identifier than the app id | 2586 // App panels should have a separate identifier than the app id |
| 2587 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 2587 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 2588 | 2588 |
| 2589 // Setting the app image image should not change the panel if it set its icon | 2589 // Setting the app image image should not change the panel if it set its icon |
| 2590 app_panel_controller->set_image_set_by_controller(true); | 2590 app_panel_controller->set_image_set_by_controller(true); |
| 2591 gfx::ImageSkia image; | 2591 gfx::ImageSkia image; |
| 2592 launcher_controller_->SetAppImage(app_id, image); | 2592 launcher_controller_->SetAppImage(app_id, image); |
| 2593 EXPECT_EQ(0, model_observer_->changed()); | 2593 EXPECT_EQ(0, model_observer_->changed()); |
| 2594 model_observer_->clear_counts(); | 2594 model_observer_->clear_counts(); |
| 2595 | 2595 |
| 2596 // Add a second app panel and verify that it get the same index as the first | 2596 // Add a second app panel and verify that it get the same index as the first |
| 2597 // one had, being added to the left of the existing panel. | 2597 // one had, being added to the left of the existing panel. |
| 2598 ShellWindowLauncherItemController* app_panel_controller2 = | 2598 AppWindowLauncherItemController* app_panel_controller2 = |
| 2599 new ShellWindowLauncherItemController( | 2599 new AppWindowLauncherItemController( |
| 2600 LauncherItemController::TYPE_APP_PANEL, | 2600 LauncherItemController::TYPE_APP_PANEL, |
| 2601 "id", | 2601 "id", |
| 2602 app_id, | 2602 app_id, |
| 2603 launcher_controller_.get()); | 2603 launcher_controller_.get()); |
| 2604 | 2604 |
| 2605 ash::ShelfID shelf_id2 = launcher_controller_->CreateAppLauncherItem( | 2605 ash::ShelfID shelf_id2 = launcher_controller_->CreateAppLauncherItem( |
| 2606 app_panel_controller2, app_id, ash::STATUS_RUNNING); | 2606 app_panel_controller2, app_id, ash::STATUS_RUNNING); |
| 2607 EXPECT_EQ(panel_index, model_observer_->last_index()); | 2607 EXPECT_EQ(panel_index, model_observer_->last_index()); |
| 2608 EXPECT_EQ(1, model_observer_->added()); | 2608 EXPECT_EQ(1, model_observer_->added()); |
| 2609 model_observer_->clear_counts(); | 2609 model_observer_->clear_counts(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2787 | 2787 |
| 2788 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2788 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2789 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2789 ASSERT_EQ(initial_size + 1, model_->items().size()); |
| 2790 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2790 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 2791 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2791 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 2792 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2792 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 2793 | 2793 |
| 2794 launcher_controller_->UnpinAppWithID("1"); | 2794 launcher_controller_->UnpinAppWithID("1"); |
| 2795 ASSERT_EQ(initial_size, model_->items().size()); | 2795 ASSERT_EQ(initial_size, model_->items().size()); |
| 2796 } | 2796 } |
| OLD | NEW |