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/ash_switches.h" | 9 #include "ash/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 Loading... | |
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, ShowInShelfWindows) { | |
1534 ash::ShelfModel* shelf_model = ash::Shell::GetInstance()->shelf_model(); | |
1535 | |
1536 //Tests without window_key parameter set | |
1537 | |
1538 // Add a window with shelf True, close it | |
1539 int item_count = shelf_model->item_count(); | |
1540 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1541 AppWindow::CreateParams params; | |
1542 params.show_in_shelf = true; | |
1543 AppWindow* window1 = | |
1544 CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1545 // There should be only 1 item added to the shelf. | |
1546 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1547 CloseAppWindow(window1); | |
1548 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1549 | |
1550 // Add a window with false, following one with true | |
1551 item_count = shelf_model->item_count(); | |
1552 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1553 | |
1554 params.show_in_shelf = false; | |
1555 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1556 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1557 params.show_in_shelf = true; | |
1558 AppWindow* window2 = | |
1559 CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1560 // There should be 2 items added to the shelf: although window1 has | |
1561 // show_in_shelf set to false, it's the first window created so its icon must | |
1562 // show up in shelf. | |
1563 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1564 CloseAppWindow(window1); | |
1565 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1566 CloseAppWindow(window2); | |
1567 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1568 | |
1569 // Open just one window with false | |
1570 item_count = shelf_model->item_count(); | |
1571 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1572 | |
1573 params.show_in_shelf = false; | |
1574 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1575 // There should be 1 item added to the shelf: although show_in_shelf is false, | |
1576 // this is the first window created. | |
1577 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1578 CloseAppWindow(window1); | |
1579 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1580 | |
1581 // Add a window with true, following one with false | |
1582 item_count = shelf_model->item_count(); | |
1583 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1584 | |
1585 params.show_in_shelf = true; | |
1586 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1587 EXPECT_EQ(item_count + 1, shelf_model->item_count()); // main window | |
1588 params.show_in_shelf = false; | |
1589 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1590 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1591 CloseAppWindow(window1); | |
1592 // There should be 1 item added to the shelf as the second window | |
1593 // is set to show_in_shelf false | |
1594 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1595 CloseAppWindow(window2); | |
1596 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1597 | |
1598 // Test closing windows in different order | |
1599 item_count = shelf_model->item_count(); | |
1600 | |
1601 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1602 params.show_in_shelf = false; | |
1603 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1604 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1605 params.show_in_shelf = false; | |
1606 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1607 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1608 params.show_in_shelf = true; | |
1609 AppWindow* window3 = | |
1610 CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1611 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1612 params.show_in_shelf = true; | |
1613 AppWindow* window4 = | |
1614 CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1615 // There should be 3 items added to the shelf. | |
1616 EXPECT_EQ(item_count + 3, shelf_model->item_count()); | |
1617 // Any window close order should be valid | |
1618 CloseAppWindow(window4); | |
1619 // Closed window4 that was shown in shelf. item_count would decrease | |
1620 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1621 CloseAppWindow(window1); | |
1622 // Closed window1 which was grouped together with window2 so item_count | |
1623 // would not decrease | |
1624 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1625 CloseAppWindow(window3); | |
1626 // Closed window3 that was shown in shelf. item_count would decrease | |
1627 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1628 CloseAppWindow(window2); | |
1629 // Closed window2 - there is no other window in that group and item_count | |
1630 // would decrease | |
1631 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1632 | |
1633 | |
1634 //Tests with window_key parameter set | |
1635 | |
1636 // Add a window with shelf True, close it | |
1637 item_count = shelf_model->item_count(); | |
1638 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1639 params.show_in_shelf = true; | |
1640 params.window_key = "window1"; | |
1641 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1642 // There should be only 1 item added to the shelf. | |
1643 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1644 CloseAppWindow(window1); | |
1645 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1646 | |
1647 // Add a window with false, following one with true | |
1648 item_count = shelf_model->item_count(); | |
1649 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1650 | |
1651 params.show_in_shelf = false; | |
1652 params.window_key = "window1"; | |
1653 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1654 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1655 params.show_in_shelf = true; | |
1656 params.window_key = "window2"; | |
1657 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1658 // There should be 2 items added to the shelf: although window1 has | |
1659 // show_in_shelf set to false, it's the first window created so its icon must | |
1660 // show up in shelf. | |
1661 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1662 CloseAppWindow(window1); | |
1663 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1664 CloseAppWindow(window2); | |
1665 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1666 | |
1667 // Open just one window with false | |
1668 item_count = shelf_model->item_count(); | |
1669 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1670 | |
1671 params.show_in_shelf = false; | |
1672 params.window_key = "window1"; | |
1673 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1674 // There should be 1 item added to the shelf: although show_in_shelf is false, | |
1675 // this is the first window created. | |
1676 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1677 CloseAppWindow(window1); | |
1678 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1679 | |
1680 // Add a window with true, following one with false | |
1681 item_count = shelf_model->item_count(); | |
1682 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1683 | |
1684 params.show_in_shelf = true; | |
1685 params.window_key = "window1"; | |
1686 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1687 EXPECT_EQ(item_count + 1, shelf_model->item_count()); // main window | |
1688 params.show_in_shelf = false; | |
1689 params.window_key = "window2"; | |
1690 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1691 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1692 CloseAppWindow(window1); | |
1693 // There should be 1 item added to the shelf as the second window | |
1694 // is set to show_in_shelf false | |
1695 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1696 CloseAppWindow(window2); | |
1697 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1698 | |
1699 // Test closing windows in different order | |
1700 item_count = shelf_model->item_count(); | |
1701 | |
1702 extension = LoadAndLaunchPlatformApp("launch", "Launched"); | |
1703 params.show_in_shelf = false; | |
1704 params.window_key = "window1"; | |
1705 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1706 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1707 params.show_in_shelf = false; | |
1708 params.window_key = "window2"; | |
1709 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1710 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1711 params.show_in_shelf = true; | |
1712 params.window_key = "window3"; | |
1713 window3 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1714 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1715 params.show_in_shelf = true; | |
1716 params.window_key = "window4"; | |
1717 window4 = CreateAppWindowFromParams(browser()->profile(), extension, params); | |
1718 // There should be 3 items added to the shelf. | |
1719 EXPECT_EQ(item_count + 3, shelf_model->item_count()); | |
1720 // Any window close order should be valid | |
1721 CloseAppWindow(window4); | |
1722 // Closed window4 that was shown in shelf. item_count would decrease | |
1723 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1724 CloseAppWindow(window1); | |
1725 // Closed window1 which was grouped together with window2 so item_count | |
1726 // would not decrease | |
1727 EXPECT_EQ(item_count + 2, shelf_model->item_count()); | |
1728 CloseAppWindow(window3); | |
1729 // Closed window3 that was shown in shelf. item_count would decrease | |
1730 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | |
1731 CloseAppWindow(window2); | |
1732 // Closed window2 - there is no other window in that group and item_count | |
1733 // would decrease | |
1734 EXPECT_EQ(item_count, shelf_model->item_count()); | |
1735 } | |
stevenjb
2016/06/14 18:33:21
This needs to be broken up
Andra Paraschiv
2016/06/28 07:04:46
Done.
| |
1736 | |
1533 // Checks that the browser Alt "tabbing" is properly done. | 1737 // Checks that the browser Alt "tabbing" is properly done. |
1534 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, | 1738 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
1535 AltNumberBrowserTabbing) { | 1739 AltNumberBrowserTabbing) { |
1536 // Get the number of items in the browser menu. | 1740 // Get the number of items in the browser menu. |
1537 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); | 1741 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); |
1538 // The first activation should create a browser at index 1 (App List @ 0). | 1742 // The first activation should create a browser at index 1 (App List @ 0). |
1539 shelf_->ActivateShelfItem(1); | 1743 shelf_->ActivateShelfItem(1); |
1540 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1744 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1541 // A second activation should not create a new instance. | 1745 // A second activation should not create a new instance. |
1542 shelf_->ActivateShelfItem(1); | 1746 shelf_->ActivateShelfItem(1); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2295 // Close all windows. | 2499 // Close all windows. |
2296 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); | 2500 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); |
2297 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); | 2501 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); |
2298 | 2502 |
2299 // Check if "Close" is removed from the context menu. | 2503 // Check if "Close" is removed from the context menu. |
2300 std::unique_ptr<LauncherContextMenu> menu2 = | 2504 std::unique_ptr<LauncherContextMenu> menu2 = |
2301 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT); | 2505 CreateLauncherContextMenu(ash::TYPE_BROWSER_SHORTCUT); |
2302 ASSERT_FALSE( | 2506 ASSERT_FALSE( |
2303 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); | 2507 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); |
2304 } | 2508 } |
OLD | NEW |