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

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

Issue 2169533002: mash: Migrate shelf app list button to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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/common/ash_switches.h" 9 #include "ash/common/ash_switches.h"
10 #include "ash/common/shelf/app_list_button.h"
10 #include "ash/common/shelf/shelf_constants.h" 11 #include "ash/common/shelf/shelf_constants.h"
11 #include "ash/common/shelf/shelf_model.h" 12 #include "ash/common/shelf/shelf_model.h"
12 #include "ash/common/wm/window_state.h" 13 #include "ash/common/wm/window_state.h"
13 #include "ash/shelf/app_list_button.h" 14 #include "ash/common/wm_shell.h"
14 #include "ash/shelf/shelf.h" 15 #include "ash/shelf/shelf.h"
15 #include "ash/shelf/shelf_button.h" 16 #include "ash/shelf/shelf_button.h"
16 #include "ash/shelf/shelf_util.h" 17 #include "ash/shelf/shelf_util.h"
17 #include "ash/shelf/shelf_view.h" 18 #include "ash/shelf/shelf_view.h"
18 #include "ash/shell.h" 19 #include "ash/shell.h"
19 #include "ash/test/shelf_test_api.h" 20 #include "ash/test/shelf_test_api.h"
20 #include "ash/test/shelf_view_test_api.h" 21 #include "ash/test/shelf_view_test_api.h"
21 #include "ash/test/shell_test_api.h" 22 #include "ash/test/shell_test_api.h"
22 #include "ash/wm/window_state_aura.h" 23 #include "ash/wm/window_state_aura.h"
23 #include "ash/wm/window_util.h" 24 #include "ash/wm/window_util.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 265
265 class ShelfAppBrowserTest : public ExtensionBrowserTest { 266 class ShelfAppBrowserTest : public ExtensionBrowserTest {
266 protected: 267 protected:
267 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) { 268 ShelfAppBrowserTest() : shelf_(NULL), model_(NULL), controller_(NULL) {
268 } 269 }
269 270
270 ~ShelfAppBrowserTest() override {} 271 ~ShelfAppBrowserTest() override {}
271 272
272 void RunTestOnMainThreadLoop() override { 273 void RunTestOnMainThreadLoop() override {
273 shelf_ = ash::Shelf::ForPrimaryDisplay(); 274 shelf_ = ash::Shelf::ForPrimaryDisplay();
274 model_ = ash::test::ShellTestApi(ash::Shell::GetInstance()).shelf_model(); 275 model_ = ash::WmShell::Get()->shelf_model();
275 controller_ = GetChromeLauncherControllerImpl(); 276 controller_ = GetChromeLauncherControllerImpl();
276 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); 277 return ExtensionBrowserTest::RunTestOnMainThreadLoop();
277 } 278 }
278 279
279 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { 280 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) {
280 LauncherItemController* item_controller = 281 LauncherItemController* item_controller =
281 controller_->GetBrowserShortcutLauncherItemController(); 282 controller_->GetBrowserShortcutLauncherItemController();
282 int items = item_controller->GetApplicationList( 283 int items = item_controller->GetApplicationList(
283 show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size(); 284 show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size();
284 // If we have at least one item, we have also a title which we remove here. 285 // If we have at least one item, we have also a title which we remove here.
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); 1528 EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
1528 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 1529 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
1529 1530
1530 // Active windows don't show attention. 1531 // Active windows don't show attention.
1531 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); 1532 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true);
1532 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 1533 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
1533 } 1534 }
1534 1535
1535 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, 1536 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest,
1536 ShowInShelfWindowsWithWindowKeySet) { 1537 ShowInShelfWindowsWithWindowKeySet) {
1537 ash::ShelfModel* shelf_model = ash::Shell::GetInstance()->shelf_model(); 1538 ash::ShelfModel* shelf_model = ash::WmShell::Get()->shelf_model();
1538 1539
1539 // Add a window with shelf True, close it 1540 // Add a window with shelf True, close it
1540 int item_count = shelf_model->item_count(); 1541 int item_count = shelf_model->item_count();
1541 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); 1542 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched");
1542 AppWindow::CreateParams params; 1543 AppWindow::CreateParams params;
1543 1544
1544 params.show_in_shelf = true; 1545 params.show_in_shelf = true;
1545 params.window_key = "window1"; 1546 params.window_key = "window1";
1546 AppWindow* window1 = 1547 AppWindow* window1 =
1547 CreateAppWindowFromParams(browser()->profile(), extension, params); 1548 CreateAppWindowFromParams(browser()->profile(), extension, params);
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 TabStripModel::CLOSE_NONE); 2263 TabStripModel::CLOSE_NONE);
2263 // Make sure that the app is really gone. 2264 // Make sure that the app is really gone.
2264 base::RunLoop().RunUntilIdle(); 2265 base::RunLoop().RunUntilIdle();
2265 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status); 2266 EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(id)->status);
2266 } 2267 }
2267 2268
2268 // Checks that a opening a settings window creates a new launcher item. 2269 // Checks that a opening a settings window creates a new launcher item.
2269 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, SettingsWindow) { 2270 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, SettingsWindow) {
2270 chrome::SettingsWindowManager* settings_manager = 2271 chrome::SettingsWindowManager* settings_manager =
2271 chrome::SettingsWindowManager::GetInstance(); 2272 chrome::SettingsWindowManager::GetInstance();
2272 ash::ShelfModel* shelf_model = ash::Shell::GetInstance()->shelf_model(); 2273 ash::ShelfModel* shelf_model = ash::WmShell::Get()->shelf_model();
2273 2274
2274 // Get the number of items in the shelf and browser menu. 2275 // Get the number of items in the shelf and browser menu.
2275 int item_count = shelf_model->item_count(); 2276 int item_count = shelf_model->item_count();
2276 size_t browser_count = NumberOfDetectedLauncherBrowsers(false); 2277 size_t browser_count = NumberOfDetectedLauncherBrowsers(false);
2277 2278
2278 // Open a settings window. Number of browser items should remain unchanged, 2279 // Open a settings window. Number of browser items should remain unchanged,
2279 // number of shelf items should increase. 2280 // number of shelf items should increase.
2280 settings_manager->ShowChromePageForProfile( 2281 settings_manager->ShowChromePageForProfile(
2281 browser()->profile(), 2282 browser()->profile(),
2282 chrome::GetSettingsUrl(std::string())); 2283 chrome::GetSettingsUrl(std::string()));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2408 // Close all windows. 2409 // Close all windows.
2409 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2410 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2410 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2411 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2411 2412
2412 // Check if "Close" is removed from the context menu. 2413 // Check if "Close" is removed from the context menu.
2413 std::unique_ptr<LauncherContextMenu> menu2 = 2414 std::unique_ptr<LauncherContextMenu> menu2 =
2414 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT); 2415 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT);
2415 ASSERT_FALSE( 2416 ASSERT_FALSE(
2416 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2417 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2417 } 2418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698