| 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.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shelf/shelf_button.h" | 10 #include "ash/shelf/shelf_button.h" |
| (...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 generator.ClickLeftButton(); | 1626 generator.ClickLeftButton(); |
| 1627 | 1627 |
| 1628 EXPECT_TRUE(service->IsAppListVisible()); | 1628 EXPECT_TRUE(service->IsAppListVisible()); |
| 1629 app_list::AppsGridView* grid_view = | 1629 app_list::AppsGridView* grid_view = |
| 1630 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). | 1630 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). |
| 1631 GetRootGridView(); | 1631 GetRootGridView(); |
| 1632 ASSERT_TRUE(grid_view); | 1632 ASSERT_TRUE(grid_view); |
| 1633 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); | 1633 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); |
| 1634 | 1634 |
| 1635 // There should be 2 items in our application list. | 1635 // There should be 2 items in our application list. |
| 1636 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); | 1636 const views::ViewModel<app_list::AppListItemView>* vm_grid = |
| 1637 grid_view->view_model_for_test(); |
| 1637 EXPECT_EQ(2, vm_grid->view_size()); | 1638 EXPECT_EQ(2, vm_grid->view_size()); |
| 1638 | 1639 |
| 1639 // Test #1: Drag an app list which does not exist yet item into the | 1640 // Test #1: Drag an app list which does not exist yet item into the |
| 1640 // launcher. Keeping it dragged, see that a new item gets created. Continuing | 1641 // launcher. Keeping it dragged, see that a new item gets created. Continuing |
| 1641 // to drag it out should remove it again. | 1642 // to drag it out should remove it again. |
| 1642 | 1643 |
| 1643 // Get over item #1 of the application list and press the mouse button. | 1644 // Get over item #1 of the application list and press the mouse button. |
| 1644 views::View* item1 = vm_grid->view_at(1); | 1645 views::View* item1 = vm_grid->view_at(1); |
| 1645 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); | 1646 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); |
| 1646 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1647 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
| 1647 bounds_grid_1.CenterPoint().y()); | 1648 bounds_grid_1.CenterPoint().y()); |
| 1648 base::MessageLoop::current()->RunUntilIdle(); | 1649 base::MessageLoop::current()->RunUntilIdle(); |
| 1649 generator.PressLeftButton(); | 1650 generator.PressLeftButton(); |
| 1650 | 1651 |
| 1651 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1652 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
| 1652 | 1653 |
| 1653 // Drag the item into the shelf and check that a new item gets created. | 1654 // Drag the item into the shelf and check that a new item gets created. |
| 1654 const views::ViewModel* vm_shelf = test.shelf_view()->view_model_for_test(); | 1655 const views::ViewModel<views::View>* vm_shelf = |
| 1656 test.shelf_view()->view_model_for_test(); |
| 1655 views::View* shelf1 = vm_shelf->view_at(1); | 1657 views::View* shelf1 = vm_shelf->view_at(1); |
| 1656 gfx::Rect bounds_shelf_1 = shelf1->GetBoundsInScreen(); | 1658 gfx::Rect bounds_shelf_1 = shelf1->GetBoundsInScreen(); |
| 1657 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), | 1659 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), |
| 1658 bounds_shelf_1.CenterPoint().y()); | 1660 bounds_shelf_1.CenterPoint().y()); |
| 1659 base::MessageLoop::current()->RunUntilIdle(); | 1661 base::MessageLoop::current()->RunUntilIdle(); |
| 1660 | 1662 |
| 1661 // Check that a new item got created. | 1663 // Check that a new item got created. |
| 1662 EXPECT_EQ(3, model_->item_count()); | 1664 EXPECT_EQ(3, model_->item_count()); |
| 1663 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1665 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
| 1664 | 1666 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 generator.ClickLeftButton(); | 1778 generator.ClickLeftButton(); |
| 1777 | 1779 |
| 1778 EXPECT_TRUE(service->IsAppListVisible()); | 1780 EXPECT_TRUE(service->IsAppListVisible()); |
| 1779 app_list::AppsGridView* grid_view = | 1781 app_list::AppsGridView* grid_view = |
| 1780 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). | 1782 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). |
| 1781 GetRootGridView(); | 1783 GetRootGridView(); |
| 1782 ASSERT_TRUE(grid_view); | 1784 ASSERT_TRUE(grid_view); |
| 1783 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); | 1785 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); |
| 1784 | 1786 |
| 1785 // There should be 2 items in our application list. | 1787 // There should be 2 items in our application list. |
| 1786 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); | 1788 const views::ViewModel<app_list::AppListItemView>* vm_grid = |
| 1789 grid_view->view_model_for_test(); |
| 1787 EXPECT_EQ(2, vm_grid->view_size()); | 1790 EXPECT_EQ(2, vm_grid->view_size()); |
| 1788 | 1791 |
| 1789 // Drag an app list item which does not exist yet in the shelf. | 1792 // Drag an app list item which does not exist yet in the shelf. |
| 1790 // Keeping it dragged, see that a new item gets created. | 1793 // Keeping it dragged, see that a new item gets created. |
| 1791 // Continuing to drag it out should remove it again. | 1794 // Continuing to drag it out should remove it again. |
| 1792 | 1795 |
| 1793 // Get over item #1 of the application list and press the mouse button. | 1796 // Get over item #1 of the application list and press the mouse button. |
| 1794 views::View* item1 = vm_grid->view_at(1); | 1797 views::View* item1 = vm_grid->view_at(1); |
| 1795 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); | 1798 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); |
| 1796 bounds_grid_1.Offset(-origin.x(), -origin.y()); | 1799 bounds_grid_1.Offset(-origin.x(), -origin.y()); |
| 1797 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1800 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
| 1798 bounds_grid_1.CenterPoint().y()); | 1801 bounds_grid_1.CenterPoint().y()); |
| 1799 base::MessageLoop::current()->RunUntilIdle(); | 1802 base::MessageLoop::current()->RunUntilIdle(); |
| 1800 generator.PressLeftButton(); | 1803 generator.PressLeftButton(); |
| 1801 | 1804 |
| 1802 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1805 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
| 1803 | 1806 |
| 1804 // Drag the item into the shelf and check that a new item gets created. | 1807 // Drag the item into the shelf and check that a new item gets created. |
| 1805 const views::ViewModel* vm_shelf = test.shelf_view()->view_model_for_test(); | 1808 const views::ViewModel<views::View>* vm_shelf = |
| 1809 test.shelf_view()->view_model_for_test(); |
| 1806 views::View* shelf1 = vm_shelf->view_at(1); | 1810 views::View* shelf1 = vm_shelf->view_at(1); |
| 1807 gfx::Rect bounds_shelf_1 = shelf1->GetBoundsInScreen(); | 1811 gfx::Rect bounds_shelf_1 = shelf1->GetBoundsInScreen(); |
| 1808 bounds_shelf_1.Offset(-origin.x(), -origin.y()); | 1812 bounds_shelf_1.Offset(-origin.x(), -origin.y()); |
| 1809 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), | 1813 generator.MoveMouseTo(bounds_shelf_1.CenterPoint().x(), |
| 1810 bounds_shelf_1.CenterPoint().y()); | 1814 bounds_shelf_1.CenterPoint().y()); |
| 1811 base::MessageLoop::current()->RunUntilIdle(); | 1815 base::MessageLoop::current()->RunUntilIdle(); |
| 1812 | 1816 |
| 1813 // Check that a new item got created. | 1817 // Check that a new item got created. |
| 1814 EXPECT_EQ(3, model_->item_count()); | 1818 EXPECT_EQ(3, model_->item_count()); |
| 1815 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1819 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), | 1954 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), |
| 1951 app_list_bounds.CenterPoint().y()); | 1955 app_list_bounds.CenterPoint().y()); |
| 1952 generator.ClickLeftButton(); | 1956 generator.ClickLeftButton(); |
| 1953 base::MessageLoop::current()->RunUntilIdle(); | 1957 base::MessageLoop::current()->RunUntilIdle(); |
| 1954 | 1958 |
| 1955 EXPECT_TRUE(service->IsAppListVisible()); | 1959 EXPECT_TRUE(service->IsAppListVisible()); |
| 1956 app_list::AppsGridView* grid_view = | 1960 app_list::AppsGridView* grid_view = |
| 1957 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). | 1961 ash::test::AppListControllerTestApi(ash::Shell::GetInstance()). |
| 1958 GetRootGridView(); | 1962 GetRootGridView(); |
| 1959 ASSERT_TRUE(grid_view); | 1963 ASSERT_TRUE(grid_view); |
| 1960 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); | 1964 const views::ViewModel<app_list::AppListItemView>* vm_grid = |
| 1965 grid_view->view_model_for_test(); |
| 1961 EXPECT_EQ(2, vm_grid->view_size()); | 1966 EXPECT_EQ(2, vm_grid->view_size()); |
| 1962 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen(); | 1967 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen(); |
| 1963 // Test now that a click does create a new application tab. | 1968 // Test now that a click does create a new application tab. |
| 1964 TabStripModel* tab_strip = browser()->tab_strip_model(); | 1969 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1965 int tab_count = tab_strip->count(); | 1970 int tab_count = tab_strip->count(); |
| 1966 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), | 1971 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
| 1967 bounds_grid_1.CenterPoint().y()); | 1972 bounds_grid_1.CenterPoint().y()); |
| 1968 generator.ClickLeftButton(); | 1973 generator.ClickLeftButton(); |
| 1969 base::MessageLoop::current()->RunUntilIdle(); | 1974 base::MessageLoop::current()->RunUntilIdle(); |
| 1970 EXPECT_EQ(tab_count + 1, tab_strip->count()); | 1975 EXPECT_EQ(tab_count + 1, tab_strip->count()); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2126 chrome::GetSettingsUrl(std::string())); | 2131 chrome::GetSettingsUrl(std::string())); |
| 2127 Browser* settings_browser = | 2132 Browser* settings_browser = |
| 2128 settings_manager->FindBrowserForProfile(browser()->profile()); | 2133 settings_manager->FindBrowserForProfile(browser()->profile()); |
| 2129 ASSERT_TRUE(settings_browser); | 2134 ASSERT_TRUE(settings_browser); |
| 2130 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); | 2135 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); |
| 2131 EXPECT_EQ(item_count + 1, shelf_model->item_count()); | 2136 EXPECT_EQ(item_count + 1, shelf_model->item_count()); |
| 2132 | 2137 |
| 2133 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded. | 2138 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded. |
| 2134 // crbug.com/230464. | 2139 // crbug.com/230464. |
| 2135 } | 2140 } |
| OLD | NEW |