Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc

Issue 2886253002: mash: remove more shell/shelf WmWindow usage. (Closed)
Patch Set: Fix WmShelf::ForWindow. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/public/cpp/shelf_item_delegate.h" 9 #include "ash/public/cpp/shelf_item_delegate.h"
10 #include "ash/public/cpp/window_properties.h" 10 #include "ash/public/cpp/window_properties.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 class ShelfAppBrowserTest : public ExtensionBrowserTest { 272 class ShelfAppBrowserTest : public ExtensionBrowserTest {
273 protected: 273 protected:
274 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) {} 274 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) {}
275 275
276 ~ShelfAppBrowserTest() override {} 276 ~ShelfAppBrowserTest() override {}
277 277
278 void SetUpOnMainThread() override { 278 void SetUpOnMainThread() override {
279 // Ensure ash starts the session and creates the shelf and controller. 279 // Ensure ash starts the session and creates the shelf and controller.
280 SessionControllerClient::FlushForTesting(); 280 SessionControllerClient::FlushForTesting();
281 281
282 shelf_ = 282 shelf_ = ash::WmShelf::ForWindow(ash::Shell::GetPrimaryRootWindow());
283 ash::WmShelf::ForWindow(ash::ShellPort::Get()->GetPrimaryRootWindow());
284 model_ = ash::Shell::Get()->shelf_model(); 283 model_ = ash::Shell::Get()->shelf_model();
285 controller_ = ChromeLauncherController::instance(); 284 controller_ = ChromeLauncherController::instance();
286 ASSERT_TRUE(controller_); 285 ASSERT_TRUE(controller_);
287 ExtensionBrowserTest::SetUpOnMainThread(); 286 ExtensionBrowserTest::SetUpOnMainThread();
288 } 287 }
289 288
290 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { 289 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) {
291 ash::ShelfItemDelegate* item_controller = 290 ash::ShelfItemDelegate* item_controller =
292 controller_->GetBrowserShortcutLauncherItemController(); 291 controller_->GetBrowserShortcutLauncherItemController();
293 return item_controller 292 return item_controller
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 base::RunLoop().RunUntilIdle(); 369 base::RunLoop().RunUntilIdle();
371 test->RunMessageLoopUntilAnimationsDone(); 370 test->RunMessageLoopUntilAnimationsDone();
372 } 371 }
373 } 372 }
374 373
375 // Creates a context menu for the existing browser shortcut item. 374 // Creates a context menu for the existing browser shortcut item.
376 std::unique_ptr<LauncherContextMenu> CreateBrowserItemContextMenu() { 375 std::unique_ptr<LauncherContextMenu> CreateBrowserItemContextMenu() {
377 int index = model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); 376 int index = model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT);
378 DCHECK_GE(index, 0); 377 DCHECK_GE(index, 0);
379 ash::ShelfItem item = model_->items()[index]; 378 ash::ShelfItem item = model_->items()[index];
380 ash::WmShelf* shelf = 379 ash::WmShelf* shelf = ash::WmShelf::ForWindow(CurrentContext());
381 ash::WmShelf::ForWindow(ash::WmWindow::Get(CurrentContext()));
382 std::unique_ptr<LauncherContextMenu> menu( 380 std::unique_ptr<LauncherContextMenu> menu(
383 LauncherContextMenu::Create(controller_, &item, shelf)); 381 LauncherContextMenu::Create(controller_, &item, shelf));
384 return menu; 382 return menu;
385 } 383 }
386 384
387 aura::Window* CurrentContext() { 385 aura::Window* CurrentContext() {
388 aura::Window* root_window = ash::Shell::GetRootWindowForNewWindows(); 386 aura::Window* root_window = ash::Shell::GetRootWindowForNewWindows();
389 DCHECK(root_window); 387 DCHECK(root_window);
390 return root_window; 388 return root_window;
391 } 389 }
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 // the launcher in the secondary monitor. 1895 // the launcher in the secondary monitor.
1898 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultiDisplayBasicDragAndDrop) { 1896 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MultiDisplayBasicDragAndDrop) {
1899 // Update the display configuration to add a secondary display. 1897 // Update the display configuration to add a secondary display.
1900 display::test::DisplayManagerTestApi(ash::Shell::Get()->display_manager()) 1898 display::test::DisplayManagerTestApi(ash::Shell::Get()->display_manager())
1901 .UpdateDisplay("800x800,801+0-800x800"); 1899 .UpdateDisplay("800x800,801+0-800x800");
1902 1900
1903 // Get a number of interfaces we need. 1901 // Get a number of interfaces we need.
1904 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U); 1902 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U);
1905 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1]; 1903 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1];
1906 ash::WmShelf* secondary_shelf = 1904 ash::WmShelf* secondary_shelf =
1907 ash::WmShelf::ForWindow(ash::WmWindow::Get(secondary_root_window)); 1905 ash::WmShelf::ForWindow(secondary_root_window);
1908 1906
1909 ui::test::EventGenerator generator(secondary_root_window, gfx::Point()); 1907 ui::test::EventGenerator generator(secondary_root_window, gfx::Point());
1910 ash::test::ShelfViewTestAPI test(secondary_shelf->GetShelfViewForTesting()); 1908 ash::test::ShelfViewTestAPI test(secondary_shelf->GetShelfViewForTesting());
1911 AppListService* service = AppListService::Get(); 1909 AppListService* service = AppListService::Get();
1912 1910
1913 // There should be two items in our shelf by this time. 1911 // There should be two items in our shelf by this time.
1914 EXPECT_EQ(2, model_->item_count()); 1912 EXPECT_EQ(2, model_->item_count());
1915 EXPECT_FALSE(service->IsAppListVisible()); 1913 EXPECT_FALSE(service->IsAppListVisible());
1916 1914
1917 // Open the app list menu and check that the drag and drop host was set. 1915 // Open the app list menu and check that the drag and drop host was set.
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 2403
2406 // Close all windows via the menu item. 2404 // Close all windows via the menu item.
2407 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2405 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2408 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2406 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2409 2407
2410 // Check if "Close" is removed from the context menu. 2408 // Check if "Close" is removed from the context menu.
2411 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); 2409 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu();
2412 ASSERT_FALSE( 2410 ASSERT_FALSE(
2413 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2411 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2414 } 2412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698