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

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

Issue 2332393003: mash: Remove shelf util functions; use WmWindow properties. (Closed)
Patch Set: Address comments. Created 4 years, 3 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_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" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/shelf/app_list_button.h" 10 #include "ash/common/shelf/app_list_button.h"
11 #include "ash/common/shelf/shelf_button.h" 11 #include "ash/common/shelf/shelf_button.h"
12 #include "ash/common/shelf/shelf_constants.h" 12 #include "ash/common/shelf/shelf_constants.h"
13 #include "ash/common/shelf/shelf_model.h" 13 #include "ash/common/shelf/shelf_model.h"
14 #include "ash/common/shelf/shelf_view.h" 14 #include "ash/common/shelf/shelf_view.h"
15 #include "ash/common/shelf/shelf_widget.h" 15 #include "ash/common/shelf/shelf_widget.h"
16 #include "ash/common/shelf/wm_shelf.h" 16 #include "ash/common/shelf/wm_shelf.h"
17 #include "ash/common/wm/window_state.h" 17 #include "ash/common/wm/window_state.h"
18 #include "ash/common/wm_shell.h" 18 #include "ash/common/wm_shell.h"
19 #include "ash/shelf/shelf_util.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_state_aura.h" 22 #include "ash/wm/window_state_aura.h"
23 #include "ash/wm/window_util.h" 23 #include "ash/wm/window_util.h"
24 #include "base/macros.h" 24 #include "base/macros.h"
25 #include "base/run_loop.h" 25 #include "base/run_loop.h"
26 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
27 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
28 #include "build/build_config.h" 28 #include "build/build_config.h"
29 #include "chrome/browser/apps/app_browsertest_util.h" 29 #include "chrome/browser/apps/app_browsertest_util.h"
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 2118
2119 // Activate again. This doesn't create new browser. 2119 // Activate again. This doesn't create new browser.
2120 // It activates window. 2120 // It activates window.
2121 item_controller->Activate(ash::LAUNCH_FROM_UNKNOWN); 2121 item_controller->Activate(ash::LAUNCH_FROM_UNKNOWN);
2122 running_browser = chrome::GetTotalBrowserCount(); 2122 running_browser = chrome::GetTotalBrowserCount();
2123 EXPECT_EQ(1u, running_browser); 2123 EXPECT_EQ(1u, running_browser);
2124 EXPECT_TRUE(item_controller->IsOpen()); 2124 EXPECT_TRUE(item_controller->IsOpen());
2125 EXPECT_FALSE(window_state->IsMinimized()); 2125 EXPECT_FALSE(window_state->IsMinimized());
2126 } 2126 }
2127 2127
2128 // Check that GetShelfIDForWindow() returns |ShelfID| of the active tab. 2128 // Check that the window's ShelfID property matches that of the active tab.
2129 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) { 2129 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, MatchingShelfIDandActiveTab) {
2130 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 2130 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
2131 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 2131 EXPECT_EQ(1, browser()->tab_strip_model()->count());
2132 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 2132 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
2133 EXPECT_EQ(2, model_->item_count()); 2133 EXPECT_EQ(2, model_->item_count());
2134 2134
2135 aura::Window* window = browser()->window()->GetNativeWindow(); 2135 ash::WmWindow* window =
2136 ash::WmWindowAura::Get(browser()->window()->GetNativeWindow());
2136 2137
2137 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); 2138 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT);
2138 ash::ShelfID browser_id = model_->items()[browser_index].id; 2139 ash::ShelfID browser_id = model_->items()[browser_index].id;
2139 EXPECT_EQ(browser_id, ash::GetShelfIDForWindow(window)); 2140 ash::ShelfID id = window->GetIntProperty(ash::WmWindowProperty::SHELF_ID);
2141 EXPECT_EQ(browser_id, id);
2140 2142
2141 ash::ShelfID app_id = CreateShortcut("app1"); 2143 ash::ShelfID app_id = CreateShortcut("app1");
2142 EXPECT_EQ(3, model_->item_count()); 2144 EXPECT_EQ(3, model_->item_count());
2143 2145
2144 // Creates a new tab for "app1" and checks that GetShelfIDForWindow() 2146 // Create and activate a new tab for "app1" and expect an application ShelfID.
2145 // returns |ShelfID| of "app1".
2146 WmShelf::ActivateShelfItem(model_->ItemIndexByID(app_id)); 2147 WmShelf::ActivateShelfItem(model_->ItemIndexByID(app_id));
2147 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 2148 EXPECT_EQ(2, browser()->tab_strip_model()->count());
2148 EXPECT_EQ(1, browser()->tab_strip_model()->active_index()); 2149 EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
2149 EXPECT_EQ(app_id, ash::GetShelfIDForWindow(window)); 2150 id = window->GetIntProperty(ash::WmWindowProperty::SHELF_ID);
2151 EXPECT_EQ(app_id, id);
2150 2152
2151 // Makes tab at index 0(NTP) as an active tab and checks that 2153 // Activate the tab at index 0 (NTP) and expect a browser ShelfID.
2152 // GetShelfIDForWindow() returns |ShelfID| of browser shortcut.
2153 browser()->tab_strip_model()->ActivateTabAt(0, false); 2154 browser()->tab_strip_model()->ActivateTabAt(0, false);
2154 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 2155 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
2155 EXPECT_EQ(browser_id, ash::GetShelfIDForWindow(window)); 2156 id = window->GetIntProperty(ash::WmWindowProperty::SHELF_ID);
2157 EXPECT_EQ(browser_id, id);
2156 } 2158 }
2157 2159
2158 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) { 2160 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, OverflowBubble) {
2159 // Make sure to have a browser window 2161 // Make sure to have a browser window
2160 chrome::NewTab(browser()); 2162 chrome::NewTab(browser());
2161 2163
2162 // No overflow yet. 2164 // No overflow yet.
2163 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble()); 2165 EXPECT_FALSE(shelf_->shelf_widget()->IsShowingOverflowBubble());
2164 2166
2165 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting()); 2167 ash::test::ShelfViewTestAPI test(shelf_->GetShelfViewForTesting());
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 2367
2366 // Close all windows via the menu item. 2368 // Close all windows via the menu item.
2367 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2369 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2368 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2370 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2369 2371
2370 // Check if "Close" is removed from the context menu. 2372 // Check if "Close" is removed from the context menu.
2371 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); 2373 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu();
2372 ASSERT_FALSE( 2374 ASSERT_FALSE(
2373 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2375 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2374 } 2376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698