| 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/aura/wm_window_aura.h" |  | 
|    10 #include "ash/common/shelf/app_list_button.h" |     9 #include "ash/common/shelf/app_list_button.h" | 
|    11 #include "ash/common/shelf/shelf_button.h" |    10 #include "ash/common/shelf/shelf_button.h" | 
|    12 #include "ash/common/shelf/shelf_constants.h" |    11 #include "ash/common/shelf/shelf_constants.h" | 
|    13 #include "ash/common/shelf/shelf_model.h" |    12 #include "ash/common/shelf/shelf_model.h" | 
|    14 #include "ash/common/shelf/shelf_view.h" |    13 #include "ash/common/shelf/shelf_view.h" | 
|    15 #include "ash/common/shelf/shelf_widget.h" |    14 #include "ash/common/shelf/shelf_widget.h" | 
|    16 #include "ash/common/shelf/wm_shelf.h" |    15 #include "ash/common/shelf/wm_shelf.h" | 
|    17 #include "ash/common/wm/window_state.h" |    16 #include "ash/common/wm/window_state.h" | 
|    18 #include "ash/common/wm_shell.h" |    17 #include "ash/common/wm_shell.h" | 
 |    18 #include "ash/common/wm_window.h" | 
|    19 #include "ash/common/wm_window_property.h" |    19 #include "ash/common/wm_window_property.h" | 
|    20 #include "ash/shell.h" |    20 #include "ash/shell.h" | 
|    21 #include "ash/test/shelf_view_test_api.h" |    21 #include "ash/test/shelf_view_test_api.h" | 
|    22 #include "ash/wm/window_properties.h" |    22 #include "ash/wm/window_properties.h" | 
|    23 #include "ash/wm/window_state_aura.h" |    23 #include "ash/wm/window_state_aura.h" | 
|    24 #include "ash/wm/window_util.h" |    24 #include "ash/wm/window_util.h" | 
|    25 #include "base/macros.h" |    25 #include "base/macros.h" | 
|    26 #include "base/run_loop.h" |    26 #include "base/run_loop.h" | 
|    27 #include "base/strings/stringprintf.h" |    27 #include "base/strings/stringprintf.h" | 
|    28 #include "base/strings/utf_string_conversions.h" |    28 #include "base/strings/utf_string_conversions.h" | 
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   365       test->RunMessageLoopUntilAnimationsDone(); |   365       test->RunMessageLoopUntilAnimationsDone(); | 
|   366     } |   366     } | 
|   367   } |   367   } | 
|   368  |   368  | 
|   369   // Creates a context menu for the existing browser shortcut item. |   369   // Creates a context menu for the existing browser shortcut item. | 
|   370   std::unique_ptr<LauncherContextMenu> CreateBrowserItemContextMenu() { |   370   std::unique_ptr<LauncherContextMenu> CreateBrowserItemContextMenu() { | 
|   371     int index = model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); |   371     int index = model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); | 
|   372     DCHECK_GE(index, 0); |   372     DCHECK_GE(index, 0); | 
|   373     ash::ShelfItem item = model_->items()[index]; |   373     ash::ShelfItem item = model_->items()[index]; | 
|   374     ash::WmShelf* shelf = |   374     ash::WmShelf* shelf = | 
|   375         ash::WmShelf::ForWindow(ash::WmWindowAura::Get(CurrentContext())); |   375         ash::WmShelf::ForWindow(ash::WmWindow::Get(CurrentContext())); | 
|   376     std::unique_ptr<LauncherContextMenu> menu( |   376     std::unique_ptr<LauncherContextMenu> menu( | 
|   377         LauncherContextMenu::Create(controller_, &item, shelf)); |   377         LauncherContextMenu::Create(controller_, &item, shelf)); | 
|   378     return menu; |   378     return menu; | 
|   379   } |   379   } | 
|   380  |   380  | 
|   381   aura::Window* CurrentContext() { |   381   aura::Window* CurrentContext() { | 
|   382     aura::Window* root_window = ash::Shell::GetTargetRootWindow(); |   382     aura::Window* root_window = ash::Shell::GetTargetRootWindow(); | 
|   383     DCHECK(root_window); |   383     DCHECK(root_window); | 
|   384     return root_window; |   384     return root_window; | 
|   385   } |   385   } | 
| (...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1903 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultiDisplayBasicDragAndDrop) { |  1903 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultiDisplayBasicDragAndDrop) { | 
|  1904   // Update the display configuration to add a secondary display. |  1904   // Update the display configuration to add a secondary display. | 
|  1905   display::test::DisplayManagerTestApi( |  1905   display::test::DisplayManagerTestApi( | 
|  1906       ash::Shell::GetInstance()->display_manager()) |  1906       ash::Shell::GetInstance()->display_manager()) | 
|  1907       .UpdateDisplay("800x800,801+0-800x800"); |  1907       .UpdateDisplay("800x800,801+0-800x800"); | 
|  1908  |  1908  | 
|  1909   // Get a number of interfaces we need. |  1909   // Get a number of interfaces we need. | 
|  1910   DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U); |  1910   DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U); | 
|  1911   aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1]; |  1911   aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1]; | 
|  1912   ash::WmShelf* secondary_shelf = |  1912   ash::WmShelf* secondary_shelf = | 
|  1913       ash::WmShelf::ForWindow(ash::WmWindowAura::Get(secondary_root_window)); |  1913       ash::WmShelf::ForWindow(ash::WmWindow::Get(secondary_root_window)); | 
|  1914  |  1914  | 
|  1915   ui::test::EventGenerator generator(secondary_root_window, gfx::Point()); |  1915   ui::test::EventGenerator generator(secondary_root_window, gfx::Point()); | 
|  1916   ash::test::ShelfViewTestAPI test(secondary_shelf->GetShelfViewForTesting()); |  1916   ash::test::ShelfViewTestAPI test(secondary_shelf->GetShelfViewForTesting()); | 
|  1917   AppListService* service = AppListService::Get(); |  1917   AppListService* service = AppListService::Get(); | 
|  1918  |  1918  | 
|  1919   // There should be two items in our shelf by this time. |  1919   // There should be two items in our shelf by this time. | 
|  1920   EXPECT_EQ(2, model_->item_count()); |  1920   EXPECT_EQ(2, model_->item_count()); | 
|  1921   EXPECT_FALSE(service->IsAppListVisible()); |  1921   EXPECT_FALSE(service->IsAppListVisible()); | 
|  1922  |  1922  | 
|  1923   // Open the app list menu and check that the drag and drop host was set. |  1923   // Open the app list menu and check that the drag and drop host was set. | 
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2171 } |  2171 } | 
|  2172  |  2172  | 
|  2173 // Check that the window's ShelfID property matches that of the active tab. |  2173 // Check that the window's ShelfID property matches that of the active tab. | 
|  2174 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) { |  2174 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) { | 
|  2175   EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |  2175   EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 
|  2176   EXPECT_EQ(1, browser()->tab_strip_model()->count()); |  2176   EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 
|  2177   EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |  2177   EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 
|  2178   EXPECT_EQ(2, model_->item_count()); |  2178   EXPECT_EQ(2, model_->item_count()); | 
|  2179  |  2179  | 
|  2180   ash::WmWindow* window = |  2180   ash::WmWindow* window = | 
|  2181       ash::WmWindowAura::Get(browser()->window()->GetNativeWindow()); |  2181       ash::WmWindow::Get(browser()->window()->GetNativeWindow()); | 
|  2182  |  2182  | 
|  2183   int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); |  2183   int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); | 
|  2184   ash::ShelfID browser_id = model_->items()[browser_index].id; |  2184   ash::ShelfID browser_id = model_->items()[browser_index].id; | 
|  2185   ash::ShelfID id = window->GetIntProperty(ash::WmWindowProperty::SHELF_ID); |  2185   ash::ShelfID id = window->GetIntProperty(ash::WmWindowProperty::SHELF_ID); | 
|  2186   EXPECT_EQ(browser_id, id); |  2186   EXPECT_EQ(browser_id, id); | 
|  2187  |  2187  | 
|  2188   ash::ShelfID app_id = CreateShortcut("app1"); |  2188   ash::ShelfID app_id = CreateShortcut("app1"); | 
|  2189   EXPECT_EQ(3, model_->item_count()); |  2189   EXPECT_EQ(3, model_->item_count()); | 
|  2190  |  2190  | 
|  2191   // Create and activate a new tab for "app1" and expect an application ShelfID. |  2191   // Create and activate a new tab for "app1" and expect an application ShelfID. | 
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2412  |  2412  | 
|  2413   // Close all windows via the menu item. |  2413   // Close all windows via the menu item. | 
|  2414   CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |  2414   CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 
|  2415   EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |  2415   EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 
|  2416  |  2416  | 
|  2417   // Check if "Close" is removed from the context menu. |  2417   // Check if "Close" is removed from the context menu. | 
|  2418   std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); |  2418   std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); | 
|  2419   ASSERT_FALSE( |  2419   ASSERT_FALSE( | 
|  2420       IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |  2420       IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 
|  2421 } |  2421 } | 
| OLD | NEW |