OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/common/shelf/app_list_button.h" | 9 #include "ash/common/shelf/app_list_button.h" |
10 #include "ash/common/shelf/shelf_button.h" | 10 #include "ash/common/shelf/shelf_button.h" |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { | 869 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { |
870 TestAppWindowRegistryObserver test_observer(browser()->profile()); | 870 TestAppWindowRegistryObserver test_observer(browser()->profile()); |
871 | 871 |
872 // Enable experimental APIs to allow panel creation. | 872 // Enable experimental APIs to allow panel creation. |
873 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 873 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
874 extensions::switches::kEnableExperimentalExtensionApis); | 874 extensions::switches::kEnableExperimentalExtensionApis); |
875 | 875 |
876 int base_shelf_item_count = shelf_model()->item_count(); | 876 int base_shelf_item_count = shelf_model()->item_count(); |
877 ExtensionTestMessageListener completed_listener("Completed", false); | 877 ExtensionTestMessageListener completed_listener("Completed", false); |
878 LoadAndLaunchPlatformApp("app_icon", "Launched"); | 878 LoadAndLaunchPlatformApp("app_icon", "Launched"); |
| 879 |
879 ASSERT_TRUE(completed_listener.WaitUntilSatisfied()); | 880 ASSERT_TRUE(completed_listener.WaitUntilSatisfied()); |
880 | 881 |
881 // Now wait until the WebContent has decoded the icons and chrome has | 882 // Now wait until the WebContent has decoded the icons and chrome has |
882 // processed it. This needs to be in a loop since the renderer runs in a | 883 // processed it. This needs to be in a loop since the renderer runs in a |
883 // different process. | 884 // different process. |
884 while (test_observer.icon_updates() < 3) { | 885 while (test_observer.icon_updates() < 4) { |
885 base::RunLoop run_loop; | 886 base::RunLoop run_loop; |
886 run_loop.RunUntilIdle(); | 887 run_loop.RunUntilIdle(); |
887 } | 888 } |
888 | 889 |
889 // This test creates one app window and one panel window. | 890 // This test creates one app window, one app window with custom icon and one |
| 891 // panel window. |
890 int shelf_item_count = shelf_model()->item_count(); | 892 int shelf_item_count = shelf_model()->item_count(); |
891 ASSERT_EQ(base_shelf_item_count + 2, shelf_item_count); | 893 ASSERT_EQ(base_shelf_item_count + 3, shelf_item_count); |
892 // The Panel will be the last item, the app second-to-last. | 894 // The Panel will be the last item, the app second-to-last. |
893 const ash::ShelfItem& app_item = | 895 const ash::ShelfItem& app_item = shelf_model()->items()[shelf_item_count - 3]; |
| 896 const ash::ShelfItem& app_custom_icon_item = |
894 shelf_model()->items()[shelf_item_count - 2]; | 897 shelf_model()->items()[shelf_item_count - 2]; |
895 const ash::ShelfItem& panel_item = | 898 const ash::ShelfItem& panel_item = |
896 shelf_model()->items()[shelf_item_count - 1]; | 899 shelf_model()->items()[shelf_item_count - 1]; |
| 900 |
897 // Icons for Apps are set by the AppWindowLauncherController, so | 901 // Icons for Apps are set by the AppWindowLauncherController, so |
898 // image_set_by_controller() should be set. | 902 // image_set_by_controller() should be set. |
899 const ash::ShelfItemDelegate* app_item_delegate = | 903 const ash::ShelfItemDelegate* app_item_delegate = |
900 GetShelfItemDelegate(app_item.id); | 904 GetShelfItemDelegate(app_item.id); |
901 EXPECT_TRUE(app_item_delegate->image_set_by_controller()); | 905 ASSERT_TRUE(app_item_delegate); |
| 906 EXPECT_FALSE(app_item_delegate->image_set_by_controller()); |
| 907 |
| 908 const ash::ShelfItemDelegate* app_custom_icon_item_delegate = |
| 909 GetShelfItemDelegate(app_custom_icon_item.id); |
| 910 ASSERT_TRUE(app_custom_icon_item_delegate); |
| 911 EXPECT_TRUE(app_custom_icon_item_delegate->image_set_by_controller()); |
| 912 |
902 // Panels are handled by ShelfWindowWatcher, not ChromeLauncherController. | 913 // Panels are handled by ShelfWindowWatcher, not ChromeLauncherController. |
903 EXPECT_EQ(nullptr, GetShelfItemDelegate(panel_item.id)); | 914 EXPECT_EQ(nullptr, GetShelfItemDelegate(panel_item.id)); |
904 // Ensure icon heights are correct (see test.js in app_icon/ test directory) | 915 // Ensure icon heights are correct (see test.js in app_icon/ test directory) |
905 EXPECT_EQ(ash::GetShelfConstant(ash::SHELF_SIZE), app_item.image.height()); | 916 EXPECT_EQ(extension_misc::EXTENSION_ICON_SMALL, app_item.image.height()); |
| 917 EXPECT_EQ(extension_misc::EXTENSION_ICON_LARGE, |
| 918 app_custom_icon_item.image.height()); |
906 EXPECT_EQ(64, panel_item.image.height()); | 919 EXPECT_EQ(64, panel_item.image.height()); |
907 } | 920 } |
908 | 921 |
909 // Test that we can launch an app with a shortcut. | 922 // Test that we can launch an app with a shortcut. |
910 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchPinned) { | 923 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchPinned) { |
911 TabStripModel* tab_strip = browser()->tab_strip_model(); | 924 TabStripModel* tab_strip = browser()->tab_strip_model(); |
912 int tab_count = tab_strip->count(); | 925 int tab_count = tab_strip->count(); |
913 ash::ShelfID shortcut_id = CreateShortcut("app1"); | 926 ash::ShelfID shortcut_id = CreateShortcut("app1"); |
914 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 927 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
915 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); | 928 WmShelf::ActivateShelfItem(model_->ItemIndexByID(shortcut_id)); |
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 | 2419 |
2407 // Close all windows via the menu item. | 2420 // Close all windows via the menu item. |
2408 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2421 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
2409 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2422 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
2410 | 2423 |
2411 // Check if "Close" is removed from the context menu. | 2424 // Check if "Close" is removed from the context menu. |
2412 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 2425 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |
2413 ASSERT_FALSE( | 2426 ASSERT_FALSE( |
2414 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2427 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
2415 } | 2428 } |
OLD | NEW |