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

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

Issue 1914993002: Enhance chrome.app.window API with better shelf integration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + Fixes v4 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/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 TestEvent click_event(ui::ET_MOUSE_PRESSED); 1523 TestEvent click_event(ui::ET_MOUSE_PRESSED);
1524 item_controller->ItemSelected(click_event); 1524 item_controller->ItemSelected(click_event);
1525 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); 1525 EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
1526 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 1526 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
1527 1527
1528 // Active windows don't show attention. 1528 // Active windows don't show attention.
1529 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); 1529 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true);
1530 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 1530 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
1531 } 1531 }
1532 1532
1533 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest,
1534 ShowInShelfWindowsWithWindowKeySet) {
1535 ash::ShelfModel* shelf_model = ash::Shell::GetInstance()->shelf_model();
1536
1537 // Add a window with shelf True, close it
1538 int item_count = shelf_model->item_count();
1539 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched");
1540 AppWindow::CreateParams params;
1541
1542 params.show_in_shelf = true;
1543 params.window_key = "window1";
1544 AppWindow* window1 =
1545 CreateAppWindowFromParams(browser()->profile(), extension, params);
1546 // There should be only 1 item added to the shelf.
1547 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1548 CloseAppWindow(window1);
1549 EXPECT_EQ(item_count, shelf_model->item_count());
1550
1551 // Add a window with false, following one with true
1552 item_count = shelf_model->item_count();
1553 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1554
1555 params.show_in_shelf = false;
1556 params.window_key = "window1";
1557 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1558 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1559 params.show_in_shelf = true;
1560 params.window_key = "window2";
1561 AppWindow* window2 =
1562 CreateAppWindowFromParams(browser()->profile(), extension, params);
1563 // There should be 2 items added to the shelf: although window1 has
1564 // show_in_shelf set to false, it's the first window created so its icon must
1565 // show up in shelf.
1566 EXPECT_EQ(item_count + 2, shelf_model->item_count());
1567 CloseAppWindow(window1);
1568 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1569 CloseAppWindow(window2);
1570 EXPECT_EQ(item_count, shelf_model->item_count());
1571
1572 // Open just one window with false
1573 item_count = shelf_model->item_count();
1574 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1575
1576 params.show_in_shelf = false;
1577 params.window_key = "window1";
1578 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1579 // There should be 1 item added to the shelf: although show_in_shelf is false,
1580 // this is the first window created.
1581 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1582 CloseAppWindow(window1);
1583 EXPECT_EQ(item_count, shelf_model->item_count());
1584
1585 // Add a window with true, following one with false
1586 item_count = shelf_model->item_count();
1587 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1588
1589 params.show_in_shelf = true;
1590 params.window_key = "window1";
1591 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1592 EXPECT_EQ(item_count + 1, shelf_model->item_count()); // main window
1593 params.show_in_shelf = false;
1594 params.window_key = "window2";
1595 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1596 EXPECT_EQ(item_count + 2, shelf_model->item_count());
1597 CloseAppWindow(window1);
1598 // There should be 1 item added to the shelf as the second window
1599 // is set to show_in_shelf false
1600 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1601 CloseAppWindow(window2);
1602 EXPECT_EQ(item_count, shelf_model->item_count());
1603
1604 // Test closing windows in different order
1605 item_count = shelf_model->item_count();
1606 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1607
1608 params.show_in_shelf = false;
1609 params.window_key = "window1";
1610 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1611 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1612 params.show_in_shelf = false;
1613 params.window_key = "window2";
1614 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1615 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1616 params.show_in_shelf = true;
1617 params.window_key = "window3";
1618 AppWindow* window3 =
1619 CreateAppWindowFromParams(browser()->profile(), extension, params);
1620 EXPECT_EQ(item_count + 2, shelf_model->item_count());
1621 params.show_in_shelf = true;
1622 params.window_key = "window4";
1623 AppWindow* window4 =
1624 CreateAppWindowFromParams(browser()->profile(), extension, params);
1625 // There should be 3 items added to the shelf.
1626 EXPECT_EQ(item_count + 3, shelf_model->item_count());
1627 // Any window close order should be valid
1628 CloseAppWindow(window4);
1629 // Closed window4 that was shown in shelf. item_count would decrease
1630 EXPECT_EQ(item_count + 2, shelf_model->item_count());
1631 CloseAppWindow(window1);
1632 // Closed window1 which was grouped together with window2 so item_count
1633 // would not decrease
1634 EXPECT_EQ(item_count + 2, shelf_model->item_count());
1635 CloseAppWindow(window3);
1636 // Closed window3 that was shown in shelf. item_count would decrease
1637 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1638 CloseAppWindow(window2);
1639 // Closed window2 - there is no other window in that group and item_count
1640 // would decrease
1641 EXPECT_EQ(item_count, shelf_model->item_count());
1642 }
1643
1533 // Checks that the browser Alt "tabbing" is properly done. 1644 // Checks that the browser Alt "tabbing" is properly done.
1534 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, 1645 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser,
1535 AltNumberBrowserTabbing) { 1646 AltNumberBrowserTabbing) {
1536 // Get the number of items in the browser menu. 1647 // Get the number of items in the browser menu.
1537 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); 1648 EXPECT_EQ(0u, chrome::GetTotalBrowserCount());
1538 // The first activation should create a browser at index 1 (App List @ 0). 1649 // The first activation should create a browser at index 1 (App List @ 0).
1539 shelf_->ActivateShelfItem(1); 1650 shelf_->ActivateShelfItem(1);
1540 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 1651 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1541 // A second activation should not create a new instance. 1652 // A second activation should not create a new instance.
1542 shelf_->ActivateShelfItem(1); 1653 shelf_->ActivateShelfItem(1);
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 // Close all windows. 2406 // Close all windows.
2296 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2407 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2297 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2408 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2298 2409
2299 // Check if "Close" is removed from the context menu. 2410 // Check if "Close" is removed from the context menu.
2300 std::unique_ptr<LauncherContextMenu> menu2 = 2411 std::unique_ptr<LauncherContextMenu> menu2 =
2301 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT); 2412 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT);
2302 ASSERT_FALSE( 2413 ASSERT_FALSE(
2303 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2414 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2304 } 2415 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698