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

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: fix for added files Created 6 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 | 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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 EXPECT_EQ(tab_count2, tab_strip2->count()); 1600 EXPECT_EQ(tab_count2, tab_strip2->count());
1601 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), 1601 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()),
1602 browser2); 1602 browser2);
1603 } 1603 }
1604 1604
1605 // Do various drag and drop interaction tests between the application list and 1605 // Do various drag and drop interaction tests between the application list and
1606 // the launcher. 1606 // the launcher.
1607 // TODO(skuhne): Test is flaky with a real compositor: crbug.com/331924 1607 // TODO(skuhne): Test is flaky with a real compositor: crbug.com/331924
1608 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DISABLED_DragAndDrop) { 1608 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DISABLED_DragAndDrop) {
1609 // Get a number of interfaces we need. 1609 // Get a number of interfaces we need.
1610 aura::test::EventGenerator generator( 1610 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(),
1611 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1611 gfx::Point());
1612 ash::test::ShelfViewTestAPI test( 1612 ash::test::ShelfViewTestAPI test(
1613 ash::test::ShelfTestAPI(shelf_).shelf_view()); 1613 ash::test::ShelfTestAPI(shelf_).shelf_view());
1614 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1614 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1615 1615
1616 // There should be two items in our launcher by this time. 1616 // There should be two items in our launcher by this time.
1617 EXPECT_EQ(2, model_->item_count()); 1617 EXPECT_EQ(2, model_->item_count());
1618 EXPECT_FALSE(service->IsAppListVisible()); 1618 EXPECT_FALSE(service->IsAppListVisible());
1619 1619
1620 // Open the app list menu and check that the drag and drop host was set. 1620 // Open the app list menu and check that the drag and drop host was set.
1621 gfx::Rect app_list_bounds = 1621 gfx::Rect app_list_bounds =
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 1746
1747 // Do basic drag and drop interaction tests between the application list and 1747 // Do basic drag and drop interaction tests between the application list and
1748 // the launcher in the secondary monitor. 1748 // the launcher in the secondary monitor.
1749 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestWithMultiMonitor, 1749 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestWithMultiMonitor,
1750 BasicDragAndDrop) { 1750 BasicDragAndDrop) {
1751 // Get a number of interfaces we need. 1751 // Get a number of interfaces we need.
1752 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U); 1752 DCHECK_EQ(ash::Shell::GetAllRootWindows().size(), 2U);
1753 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1]; 1753 aura::Window* secondary_root_window = ash::Shell::GetAllRootWindows()[1];
1754 ash::Shelf* secondary_shelf = ash::Shelf::ForWindow(secondary_root_window); 1754 ash::Shelf* secondary_shelf = ash::Shelf::ForWindow(secondary_root_window);
1755 1755
1756 aura::test::EventGenerator generator(secondary_root_window, gfx::Point()); 1756 ui::test::EventGenerator generator(secondary_root_window, gfx::Point());
1757 ash::test::ShelfViewTestAPI test( 1757 ash::test::ShelfViewTestAPI test(
1758 ash::test::ShelfTestAPI(secondary_shelf).shelf_view()); 1758 ash::test::ShelfTestAPI(secondary_shelf).shelf_view());
1759 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1759 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1760 1760
1761 // There should be two items in our shelf by this time. 1761 // There should be two items in our shelf by this time.
1762 EXPECT_EQ(2, model_->item_count()); 1762 EXPECT_EQ(2, model_->item_count());
1763 EXPECT_FALSE(service->IsAppListVisible()); 1763 EXPECT_FALSE(service->IsAppListVisible());
1764 1764
1765 // Open the app list menu and check that the drag and drop host was set. 1765 // Open the app list menu and check that the drag and drop host was set.
1766 gfx::Rect app_list_bounds = 1766 gfx::Rect app_list_bounds =
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 1825
1826 // Dropping it should keep the shelf as it originally was. 1826 // Dropping it should keep the shelf as it originally was.
1827 generator.ReleaseLeftButton(); 1827 generator.ReleaseLeftButton();
1828 base::MessageLoop::current()->RunUntilIdle(); 1828 base::MessageLoop::current()->RunUntilIdle();
1829 EXPECT_EQ(2, model_->item_count()); 1829 EXPECT_EQ(2, model_->item_count());
1830 } 1830 }
1831 #endif 1831 #endif
1832 1832
1833 // Do tests for removal of items from the shelf by dragging. 1833 // Do tests for removal of items from the shelf by dragging.
1834 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DragOffShelf) { 1834 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, DragOffShelf) {
1835 aura::test::EventGenerator generator( 1835 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(),
1836 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1836 gfx::Point());
1837 ash::test::ShelfViewTestAPI test( 1837 ash::test::ShelfViewTestAPI test(
1838 ash::test::ShelfTestAPI(shelf_).shelf_view()); 1838 ash::test::ShelfTestAPI(shelf_).shelf_view());
1839 test.SetAnimationDuration(1); // Speed up animations for test. 1839 test.SetAnimationDuration(1); // Speed up animations for test.
1840 // Create a known application and check that we have 3 items in the shelf. 1840 // Create a known application and check that we have 3 items in the shelf.
1841 CreateShortcut("app1"); 1841 CreateShortcut("app1");
1842 test.RunMessageLoopUntilAnimationsDone(); 1842 test.RunMessageLoopUntilAnimationsDone();
1843 EXPECT_EQ(3, model_->item_count()); 1843 EXPECT_EQ(3, model_->item_count());
1844 1844
1845 // Test #1: Ripping out the browser item should not change anything. 1845 // Test #1: Ripping out the browser item should not change anything.
1846 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT); 1846 int browser_index = GetIndexOfShelfItemType(ash::TYPE_BROWSER_SHORTCUT);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 1928
1929 // Rip off again and the overflow button should has disappeared. 1929 // Rip off again and the overflow button should has disappeared.
1930 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM); 1930 RipOffItemIndex(app_index, &generator, &test, RIP_OFF_ITEM);
1931 EXPECT_EQ(total_count - 2, model_->item_count()); 1931 EXPECT_EQ(total_count - 2, model_->item_count());
1932 EXPECT_FALSE(test.IsOverflowButtonVisible()); 1932 EXPECT_FALSE(test.IsOverflowButtonVisible());
1933 } 1933 }
1934 1934
1935 // Check that clicking on an app shelf item launches a new browser. 1935 // Check that clicking on an app shelf item launches a new browser.
1936 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ClickItem) { 1936 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, ClickItem) {
1937 // Get a number of interfaces we need. 1937 // Get a number of interfaces we need.
1938 aura::test::EventGenerator generator( 1938 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow(),
1939 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1939 gfx::Point());
1940 ash::test::ShelfViewTestAPI test( 1940 ash::test::ShelfViewTestAPI test(
1941 ash::test::ShelfTestAPI(shelf_).shelf_view()); 1941 ash::test::ShelfTestAPI(shelf_).shelf_view());
1942 AppListService* service = AppListService::Get(chrome::GetActiveDesktop()); 1942 AppListService* service = AppListService::Get(chrome::GetActiveDesktop());
1943 // There should be two items in our shelf by this time. 1943 // There should be two items in our shelf by this time.
1944 EXPECT_EQ(2, model_->item_count()); 1944 EXPECT_EQ(2, model_->item_count());
1945 EXPECT_FALSE(service->IsAppListVisible()); 1945 EXPECT_FALSE(service->IsAppListVisible());
1946 1946
1947 // Open the app list menu and check that the drag and drop host was set. 1947 // Open the app list menu and check that the drag and drop host was set.
1948 gfx::Rect app_list_bounds = 1948 gfx::Rect app_list_bounds =
1949 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen(); 1949 test.shelf_view()->GetAppListButtonView()->GetBoundsInScreen();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 chrome::GetSettingsUrl(std::string())); 2126 chrome::GetSettingsUrl(std::string()));
2127 Browser* settings_browser = 2127 Browser* settings_browser =
2128 settings_manager->FindBrowserForProfile(browser()->profile()); 2128 settings_manager->FindBrowserForProfile(browser()->profile());
2129 ASSERT_TRUE(settings_browser); 2129 ASSERT_TRUE(settings_browser);
2130 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false)); 2130 EXPECT_EQ(browser_count, NumberOfDetectedLauncherBrowsers(false));
2131 EXPECT_EQ(item_count + 1, shelf_model->item_count()); 2131 EXPECT_EQ(item_count + 1, shelf_model->item_count());
2132 2132
2133 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded. 2133 // TODO(stevenjb): Test multiprofile on Chrome OS when test support is addded.
2134 // crbug.com/230464. 2134 // crbug.com/230464.
2135 } 2135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698