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

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

Issue 23449033: [ash] Remove Launcher::GetLauncherViewForTest() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing class keyword Created 7 years, 3 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
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/native_app_window.h" 7 #include "apps/native_app_window.h"
8 #include "apps/shell_window.h" 8 #include "apps/shell_window.h"
9 #include "apps/shell_window_registry.h" 9 #include "apps/shell_window_registry.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/display/display_controller.h" 11 #include "ash/display/display_controller.h"
12 #include "ash/launcher/launcher.h" 12 #include "ash/launcher/launcher.h"
13 #include "ash/launcher/launcher_button.h" 13 #include "ash/launcher/launcher_button.h"
14 #include "ash/launcher/launcher_model.h" 14 #include "ash/launcher/launcher_model.h"
15 #include "ash/launcher/launcher_util.h" 15 #include "ash/launcher/launcher_util.h"
16 #include "ash/launcher/launcher_view.h" 16 #include "ash/launcher/launcher_view.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "ash/test/launcher_test_api.h"
18 #include "ash/test/launcher_view_test_api.h" 19 #include "ash/test/launcher_view_test_api.h"
19 #include "ash/test/shell_test_api.h" 20 #include "ash/test/shell_test_api.h"
20 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
21 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
23 #include "chrome/browser/apps/app_browsertest_util.h" 24 #include "chrome/browser/apps/app_browsertest_util.h"
24 #include "chrome/browser/automation/automation_util.h" 25 #include "chrome/browser/automation/automation_util.h"
25 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/extensions/extension_apitest.h" 27 #include "chrome/browser/extensions/extension_apitest.h"
27 #include "chrome/browser/extensions/extension_browsertest.h" 28 #include "chrome/browser/extensions/extension_browsertest.h"
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), 1483 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()),
1483 browser2); 1484 browser2);
1484 } 1485 }
1485 1486
1486 // Do various drag and drop interaction tests between the application list and 1487 // Do various drag and drop interaction tests between the application list and
1487 // the launcher. 1488 // the launcher.
1488 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) { 1489 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) {
1489 // Get a number of interfaces we need. 1490 // Get a number of interfaces we need.
1490 aura::test::EventGenerator generator( 1491 aura::test::EventGenerator generator(
1491 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1492 ash::Shell::GetPrimaryRootWindow(), gfx::Point());
1492 ash::test::LauncherViewTestAPI test(launcher_->GetLauncherViewForTest()); 1493 ash::test::LauncherViewTestAPI test(
1494 ash::test::LauncherTestAPI(launcher_).launcher_view());
1493 AppListService* service = AppListService::Get(); 1495 AppListService* service = AppListService::Get();
1494 1496
1495 // There should be two items in our launcher by this time. 1497 // There should be two items in our launcher by this time.
1496 EXPECT_EQ(2, model_->item_count()); 1498 EXPECT_EQ(2, model_->item_count());
1497 EXPECT_FALSE(service->IsAppListVisible()); 1499 EXPECT_FALSE(service->IsAppListVisible());
1498 1500
1499 // Open the app list menu and check that the drag and drop host was set. 1501 // Open the app list menu and check that the drag and drop host was set.
1500 gfx::Rect app_list_bounds = 1502 gfx::Rect app_list_bounds =
1501 test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen(); 1503 test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen();
1502 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1504 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 generator.ReleaseLeftButton(); 1588 generator.ReleaseLeftButton();
1587 base::MessageLoop::current()->RunUntilIdle(); 1589 base::MessageLoop::current()->RunUntilIdle();
1588 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1590 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1589 EXPECT_EQ(3, model_->item_count()); // And it remains that way. 1591 EXPECT_EQ(3, model_->item_count()); // And it remains that way.
1590 } 1592 }
1591 1593
1592 // Do tests for removal of items from the shelf by dragging. 1594 // Do tests for removal of items from the shelf by dragging.
1593 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragOffShelf) { 1595 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragOffShelf) {
1594 aura::test::EventGenerator generator( 1596 aura::test::EventGenerator generator(
1595 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1597 ash::Shell::GetPrimaryRootWindow(), gfx::Point());
1596 ash::test::LauncherViewTestAPI test(launcher_->GetLauncherViewForTest()); 1598 ash::test::LauncherViewTestAPI test(
1599 ash::test::LauncherTestAPI(launcher_).launcher_view());
1597 1600
1598 // Create a known application and check that we have 3 items in the launcher. 1601 // Create a known application and check that we have 3 items in the launcher.
1599 CreateShortcut("app1"); 1602 CreateShortcut("app1");
1600 EXPECT_EQ(3, model_->item_count()); 1603 EXPECT_EQ(3, model_->item_count());
1601 1604
1602 // Test #1: Ripping out the browser item should not change anything. 1605 // Test #1: Ripping out the browser item should not change anything.
1603 int browser_index = GetIndexOfLauncherItemType(ash::TYPE_BROWSER_SHORTCUT); 1606 int browser_index = GetIndexOfLauncherItemType(ash::TYPE_BROWSER_SHORTCUT);
1604 EXPECT_LE(0, browser_index); 1607 EXPECT_LE(0, browser_index);
1605 RipOffItemIndex(browser_index, &generator, &test, RIP_OFF_ITEM); 1608 RipOffItemIndex(browser_index, &generator, &test, RIP_OFF_ITEM);
1606 // => It should not have been removed and the location should be unchanged. 1609 // => It should not have been removed and the location should be unchanged.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 base::MessageLoop::current()->RunUntilIdle(); 1653 base::MessageLoop::current()->RunUntilIdle();
1651 EXPECT_EQ(2, model_->item_count()); // And it remains that way. 1654 EXPECT_EQ(2, model_->item_count()); // And it remains that way.
1652 EXPECT_EQ(-1, GetIndexOfLauncherItemType(ash::TYPE_APP_SHORTCUT)); 1655 EXPECT_EQ(-1, GetIndexOfLauncherItemType(ash::TYPE_APP_SHORTCUT));
1653 } 1656 }
1654 1657
1655 // Check that clicking on an app launcher item launches a new browser. 1658 // Check that clicking on an app launcher item launches a new browser.
1656 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ClickItem) { 1659 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ClickItem) {
1657 // Get a number of interfaces we need. 1660 // Get a number of interfaces we need.
1658 aura::test::EventGenerator generator( 1661 aura::test::EventGenerator generator(
1659 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); 1662 ash::Shell::GetPrimaryRootWindow(), gfx::Point());
1660 ash::test::LauncherViewTestAPI test(launcher_->GetLauncherViewForTest()); 1663 ash::test::LauncherViewTestAPI test(
1664 ash::test::LauncherTestAPI(launcher_).launcher_view());
1661 AppListService* service = AppListService::Get(); 1665 AppListService* service = AppListService::Get();
1662 // There should be two items in our launcher by this time. 1666 // There should be two items in our launcher by this time.
1663 EXPECT_EQ(2, model_->item_count()); 1667 EXPECT_EQ(2, model_->item_count());
1664 EXPECT_FALSE(service->IsAppListVisible()); 1668 EXPECT_FALSE(service->IsAppListVisible());
1665 1669
1666 // Open the app list menu and check that the drag and drop host was set. 1670 // Open the app list menu and check that the drag and drop host was set.
1667 gfx::Rect app_list_bounds = 1671 gfx::Rect app_list_bounds =
1668 test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen(); 1672 test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen();
1669 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1673 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1670 app_list_bounds.CenterPoint().y()); 1674 app_list_bounds.CenterPoint().y());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 EXPECT_EQ(browser_id, controller_->GetIDByWindow(window)); 1754 EXPECT_EQ(browser_id, controller_->GetIDByWindow(window));
1751 } 1755 }
1752 1756
1753 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, OverflowBubble) { 1757 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, OverflowBubble) {
1754 // Make sure to have a browser window 1758 // Make sure to have a browser window
1755 chrome::NewTab(browser()); 1759 chrome::NewTab(browser());
1756 1760
1757 // No overflow yet. 1761 // No overflow yet.
1758 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); 1762 EXPECT_FALSE(launcher_->IsShowingOverflowBubble());
1759 1763
1760 ash::test::LauncherViewTestAPI test(launcher_->GetLauncherViewForTest()); 1764 ash::test::LauncherViewTestAPI test(
1765 ash::test::LauncherTestAPI(launcher_).launcher_view());
1761 1766
1762 int items_added = 0; 1767 int items_added = 0;
1763 while (!test.IsOverflowButtonVisible()) { 1768 while (!test.IsOverflowButtonVisible()) {
1764 std::string fake_app_id = base::StringPrintf("fake_app_%d", items_added); 1769 std::string fake_app_id = base::StringPrintf("fake_app_%d", items_added);
1765 PinFakeApp(fake_app_id); 1770 PinFakeApp(fake_app_id);
1766 1771
1767 ++items_added; 1772 ++items_added;
1768 ASSERT_LT(items_added, 10000); 1773 ASSERT_LT(items_added, 10000);
1769 } 1774 }
1770 1775
1771 // Now show overflow bubble. 1776 // Now show overflow bubble.
1772 test.ShowOverflowBubble(); 1777 test.ShowOverflowBubble();
1773 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); 1778 EXPECT_TRUE(launcher_->IsShowingOverflowBubble());
1774 1779
1775 // Unpin first pinned app and there should be no crash. 1780 // Unpin first pinned app and there should be no crash.
1776 controller_->UnpinAppWithID(std::string("fake_app_0")); 1781 controller_->UnpinAppWithID(std::string("fake_app_0"));
1777 1782
1778 test.RunMessageLoopUntilAnimationsDone(); 1783 test.RunMessageLoopUntilAnimationsDone();
1779 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); 1784 EXPECT_FALSE(launcher_->IsShowingOverflowBubble());
1780 } 1785 }
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_layout_manager_unittest.cc ('k') | chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698