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