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

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

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase at r285842 Created 6 years, 4 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 | Annotate | Revision Log
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.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include "apps/app_window.h" 7 #include "apps/app_window.h"
8 #include "apps/app_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "apps/ui/native_app_window.h" 9 #include "apps/ui/native_app_window.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "content/public/browser/notification_service.h" 51 #include "content/public/browser/notification_service.h"
52 #include "content/public/browser/notification_source.h" 52 #include "content/public/browser/notification_source.h"
53 #include "content/public/browser/web_contents.h" 53 #include "content/public/browser/web_contents.h"
54 #include "content/public/test/browser_test_utils.h" 54 #include "content/public/test/browser_test_utils.h"
55 #include "extensions/browser/extension_system.h" 55 #include "extensions/browser/extension_system.h"
56 #include "extensions/common/constants.h" 56 #include "extensions/common/constants.h"
57 #include "extensions/common/switches.h" 57 #include "extensions/common/switches.h"
58 #include "testing/gtest/include/gtest/gtest.h" 58 #include "testing/gtest/include/gtest/gtest.h"
59 #include "ui/app_list/views/apps_grid_view.h" 59 #include "ui/app_list/views/apps_grid_view.h"
60 #include "ui/aura/client/aura_constants.h" 60 #include "ui/aura/client/aura_constants.h"
61 #include "ui/aura/test/event_generator.h"
62 #include "ui/aura/window.h" 61 #include "ui/aura/window.h"
63 #include "ui/events/event.h" 62 #include "ui/events/event.h"
63 #include "ui/events/test/event_generator.h"
64 64
65 using apps::AppWindow; 65 using apps::AppWindow;
66 using extensions::Extension; 66 using extensions::Extension;
67 using content::WebContents; 67 using content::WebContents;
68 68
69 namespace { 69 namespace {
70 70
71 class TestEvent : public ui::Event { 71 class TestEvent : public ui::Event {
72 public: 72 public:
73 explicit TestEvent(ui::EventType type) 73 explicit TestEvent(ui::EventType type)
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 name, model_->item_count()); 261 name, model_->item_count());
262 } 262 }
263 263
264 // Get the index of an item which has the given type. 264 // Get the index of an item which has the given type.
265 int GetIndexOfShelfItemType(ash::ShelfItemType type) { 265 int GetIndexOfShelfItemType(ash::ShelfItemType type) {
266 return model_->GetItemIndexForType(type); 266 return model_->GetItemIndexForType(type);
267 } 267 }
268 268
269 // Try to rip off |item_index|. 269 // Try to rip off |item_index|.
270 void RipOffItemIndex(int index, 270 void RipOffItemIndex(int index,
271 aura::test::EventGenerator* generator, 271 ui::test::EventGenerator* generator,
272 ash::test::ShelfViewTestAPI* test, 272 ash::test::ShelfViewTestAPI* test,
273 RipOffCommand command) { 273 RipOffCommand command) {
274 ash::ShelfButton* button = test->GetButton(index); 274 ash::ShelfButton* button = test->GetButton(index);
275 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); 275 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint();
276 gfx::Point rip_off_point(start_point.x(), 0); 276 gfx::Point rip_off_point(start_point.x(), 0);
277 generator->MoveMouseTo(start_point.x(), start_point.y()); 277 generator->MoveMouseTo(start_point.x(), start_point.y());
278 base::MessageLoop::current()->RunUntilIdle(); 278 base::MessageLoop::current()->RunUntilIdle();
279 generator->PressLeftButton(); 279 generator->PressLeftButton();
280 base::MessageLoop::current()->RunUntilIdle(); 280 base::MessageLoop::current()->RunUntilIdle();
281 generator->MoveMouseTo(rip_off_point.x(), rip_off_point.y()); 281 generator->MoveMouseTo(rip_off_point.x(), rip_off_point.y());
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 EXPECT_EQ(tab_count2, tab_strip2->count()); 1599 EXPECT_EQ(tab_count2, tab_strip2->count());
1600 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), 1600 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()),
1601 browser2); 1601 browser2);
1602 } 1602 }
1603 1603
1604 // Do various drag and drop interaction tests between the application list and 1604 // Do various drag and drop interaction tests between the application list and
1605 // the launcher. 1605 // the launcher.
1606 // TODO(skuhne): Test is flaky with a real compositor: crbug.com/331924 1606 // TODO(skuhne): Test is flaky with a real compositor: crbug.com/331924
1607 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DISABLED_DragAndDrop) { 1607 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DISABLED_DragAndDrop) {
1608 // Get a number of interfaces we need. 1608 // Get a number of interfaces we need.
1609 aura::test::EventGenerator generator( 1609 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(),
1610 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1610 gfx::Point());
1611 ash::test::ShelfViewTestAPI test( 1611 ash::test::ShelfViewTestAPI test(
1612 ash::test::ShelfTestAPI(shelf_).shelf_view()); 1612 ash::test::ShelfTestAPI(shelf_).shelf_view());
1613 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1613 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1614 1614
1615 // There should be two items in our launcher by this time. 1615 // There should be two items in our launcher by this time.
1616 EXPECT_EQ(2, model_->item_count()); 1616 EXPECT_EQ(2, model_->item_count());
1617 EXPECT_FALSE(service->IsAppListVisible()); 1617 EXPECT_FALSE(service->IsAppListVisible());
1618 1618
1619 // Open the app list menu and check that the drag and drop host was set. 1619 // Open the app list menu and check that the drag and drop host was set.
1620 gfx::Rect app_list_bounds = 1620 gfx::Rect app_list_bounds =
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 1745
1746 // Do basic drag and drop interaction tests between the application list and 1746 // Do basic drag and drop interaction tests between the application list and
1747 // the launcher in the secondary monitor. 1747 // the launcher in the secondary monitor.
1748 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestWithMultiMonitor, 1748 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestWithMultiMonitor,
1749 BasicDragAndDrop) { 1749 BasicDragAndDrop) {
1750 // Get a number of interfaces we need. 1750 // Get a number of interfaces we need.
1751 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U); 1751 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U);
1752 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1]; 1752 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1];
1753 ash::Shelf* secondary_shelf = ash::Shelf::ForWindow(secondary_root_window); 1753 ash::Shelf* secondary_shelf = ash::Shelf::ForWindow(secondary_root_window);
1754 1754
1755 aura::test::EventGenerator generator(secondary_root_window, gfx::Point()); 1755 ui::test::EventGenerator generator(secondary_root_window, gfx::Point());
1756 ash::test::ShelfViewTestAPI test( 1756 ash::test::ShelfViewTestAPI test(
1757 ash::test::ShelfTestAPI(secondary_shelf).shelf_view()); 1757 ash::test::ShelfTestAPI(secondary_shelf).shelf_view());
1758 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1758 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1759 1759
1760 // There should be two items in our shelf by this time. 1760 // There should be two items in our shelf by this time.
1761 EXPECT_EQ(2, model_->item_count()); 1761 EXPECT_EQ(2, model_->item_count());
1762 EXPECT_FALSE(service->IsAppListVisible()); 1762 EXPECT_FALSE(service->IsAppListVisible());
1763 1763
1764 // Open the app list menu and check that the drag and drop host was set. 1764 // Open the app list menu and check that the drag and drop host was set.
1765 gfx::Rect app_list_bounds = 1765 gfx::Rect app_list_bounds =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 1824
1825 // Dropping it should keep the shelf as it originally was. 1825 // Dropping it should keep the shelf as it originally was.
1826 generator.ReleaseLeftButton(); 1826 generator.ReleaseLeftButton();
1827 base::MessageLoop::current()->RunUntilIdle(); 1827 base::MessageLoop::current()->RunUntilIdle();
1828 EXPECT_EQ(2, model_->item_count()); 1828 EXPECT_EQ(2, model_->item_count());
1829 } 1829 }
1830 #endif 1830 #endif
1831 1831
1832 // Do tests for removal of items from the shelf by dragging. 1832 // Do tests for removal of items from the shelf by dragging.
1833 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DragOffShelf) { 1833 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DragOffShelf) {
1834 aura::test::EventGenerator generator( 1834 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(),
1835 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1835 gfx::Point());
1836 ash::test::ShelfViewTestAPI test( 1836 ash::test::ShelfViewTestAPI test(
1837 ash::test::ShelfTestAPI(shelf_).shelf_view()); 1837 ash::test::ShelfTestAPI(shelf_).shelf_view());
1838 test.SetAnimationDuration(1); // Speed up animations for test. 1838 test.SetAnimationDuration(1); // Speed up animations for test.
1839 // Create a known application and check that we have 3 items in the shelf. 1839 // Create a known application and check that we have 3 items in the shelf.
1840 CreateShortcut("app1"); 1840 CreateShortcut("app1");
1841 test.RunMessageLoopUntilAnimationsDone(); 1841 test.RunMessageLoopUntilAnimationsDone();
1842 EXPECT_EQ(3, model_->item_count()); 1842 EXPECT_EQ(3, model_->item_count());
1843 1843
1844 // Test #1: Ripping out the browser item should not change anything. 1844 // Test #1: Ripping out the browser item should not change anything.
1845 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); 1845 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 1927
1928 // Rip off again and the overflow button should has disappeared. 1928 // Rip off again and the overflow button should has disappeared.
1929 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM); 1929 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM);
1930 EXPECT_EQ(total_count - 2, model_->item_count()); 1930 EXPECT_EQ(total_count - 2, model_->item_count());
1931 EXPECT_FALSE(test.IsOverflowButtonVisible()); 1931 EXPECT_FALSE(test.IsOverflowButtonVisible());
1932 } 1932 }
1933 1933
1934 // Check that clicking on an app shelf item launches a new browser. 1934 // Check that clicking on an app shelf item launches a new browser.
1935 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ClickItem) { 1935 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ClickItem) {
1936 // Get a number of interfaces we need. 1936 // Get a number of interfaces we need.
1937 aura::test::EventGenerator generator( 1937 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(),
1938 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1938 gfx::Point());
1939 ash::test::ShelfViewTestAPI test( 1939 ash::test::ShelfViewTestAPI test(
1940 ash::test::ShelfTestAPI(shelf_).shelf_view()); 1940 ash::test::ShelfTestAPI(shelf_).shelf_view());
1941 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1941 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1942 // There should be two items in our shelf by this time. 1942 // There should be two items in our shelf by this time.
1943 EXPECT_EQ(2, model_->item_count()); 1943 EXPECT_EQ(2, model_->item_count());
1944 EXPECT_FALSE(service->IsAppListVisible()); 1944 EXPECT_FALSE(service->IsAppListVisible());
1945 1945
1946 // Open the app list menu and check that the drag and drop host was set. 1946 // Open the app list menu and check that the drag and drop host was set.
1947 gfx::Rect app_list_bounds = 1947 gfx::Rect app_list_bounds =
1948 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1948 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 chrome::GetSettingsUrl(std::string())); 2125 chrome::GetSettingsUrl(std::string()));
2126 Browser* settings_browser = 2126 Browser* settings_browser =
2127 settings_manager->FindBrowserForProfile(browser()->profile()); 2127 settings_manager->FindBrowserForProfile(browser()->profile());
2128 ASSERT_TRUE(settings_browser); 2128 ASSERT_TRUE(settings_browser);
2129 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); 2129 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false));
2130 EXPECT_EQ(item_count + 1, shelf_model->item_count()); 2130 EXPECT_EQ(item_count + 1, shelf_model->item_count());
2131 2131
2132 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded. 2132 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded.
2133 // crbug.com/230464. 2133 // crbug.com/230464.
2134 } 2134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698