| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
| 10 #include "ash/launcher/launcher_model.h" | 10 #include "ash/launcher/launcher_model.h" |
| (...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 bounds_launcher_1.CenterPoint().y()); | 1441 bounds_launcher_1.CenterPoint().y()); |
| 1442 base::MessageLoop::current()->RunUntilIdle(); | 1442 base::MessageLoop::current()->RunUntilIdle(); |
| 1443 EXPECT_EQ(3, model_->item_count()); // No new item got added. | 1443 EXPECT_EQ(3, model_->item_count()); // No new item got added. |
| 1444 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1444 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
| 1445 generator.ReleaseLeftButton(); | 1445 generator.ReleaseLeftButton(); |
| 1446 base::MessageLoop::current()->RunUntilIdle(); | 1446 base::MessageLoop::current()->RunUntilIdle(); |
| 1447 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); | 1447 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); |
| 1448 EXPECT_EQ(3, model_->item_count()); // And it remains that way. | 1448 EXPECT_EQ(3, model_->item_count()); // And it remains that way. |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 // Check that clicking on an app launcher item launches a new browser. |
| 1452 IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, ClickItem) { |
| 1453 // Get a number of interfaces we need. |
| 1454 aura::test::EventGenerator generator( |
| 1455 ash::Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 1456 ash::test::LauncherViewTestAPI test(launcher_->GetLauncherViewForTest()); |
| 1457 AppListService* service = AppListService::Get(); |
| 1458 // There should be two items in our launcher by this time. |
| 1459 EXPECT_EQ(2, model_->item_count()); |
| 1460 EXPECT_FALSE(service->IsAppListVisible()); |
| 1461 |
| 1462 // Open the app list menu and check that the drag and drop host was set. |
| 1463 gfx::Rect app_list_bounds = |
| 1464 test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen(); |
| 1465 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), |
| 1466 app_list_bounds.CenterPoint().y()); |
| 1467 generator.ClickLeftButton(); |
| 1468 base::MessageLoop::current()->RunUntilIdle(); |
| 1469 |
| 1470 EXPECT_TRUE(service->IsAppListVisible()); |
| 1471 app_list::AppsGridView* grid_view = |
| 1472 app_list::AppsGridView::GetLastGridViewForTest(); |
| 1473 ASSERT_TRUE(grid_view); |
| 1474 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); |
| 1475 EXPECT_EQ(2, vm_grid->view_size()); |
| 1476 gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen(); |
| 1477 // Test now that a click does create a new application tab. |
| 1478 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 1479 int tab_count = tab_strip->count(); |
| 1480 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), |
| 1481 bounds_grid_1.CenterPoint().y()); |
| 1482 generator.ClickLeftButton(); |
| 1483 base::MessageLoop::current()->RunUntilIdle(); |
| 1484 EXPECT_EQ(tab_count + 1, tab_strip->count()); |
| 1485 } |
| 1486 |
| 1451 // Check LauncherItemController of Browser Shortcut functionality. | 1487 // Check LauncherItemController of Browser Shortcut functionality. |
| 1452 IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTestNoDefaultBrowser, | 1488 IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTestNoDefaultBrowser, |
| 1453 BrowserShortcutLauncherItemController) { | 1489 BrowserShortcutLauncherItemController) { |
| 1454 ChromeLauncherControllerPerApp* controller = | 1490 ChromeLauncherControllerPerApp* controller = |
| 1455 static_cast<ChromeLauncherControllerPerApp*>(launcher_->delegate()); | 1491 static_cast<ChromeLauncherControllerPerApp*>(launcher_->delegate()); |
| 1456 LauncherItemController* item_controller = | 1492 LauncherItemController* item_controller = |
| 1457 controller->GetBrowserShortcutLauncherItemController(); | 1493 controller->GetBrowserShortcutLauncherItemController(); |
| 1458 | 1494 |
| 1459 // Get the number of browsers. | 1495 // Get the number of browsers. |
| 1460 size_t running_browser = chrome::GetTotalBrowserCount(); | 1496 size_t running_browser = chrome::GetTotalBrowserCount(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1474 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 1510 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); |
| 1475 | 1511 |
| 1476 // Activate again. This doesn't create new browser. | 1512 // Activate again. This doesn't create new browser. |
| 1477 // It activates window. | 1513 // It activates window. |
| 1478 item_controller->Activate(); | 1514 item_controller->Activate(); |
| 1479 running_browser = chrome::GetTotalBrowserCount(); | 1515 running_browser = chrome::GetTotalBrowserCount(); |
| 1480 EXPECT_EQ(1u, running_browser); | 1516 EXPECT_EQ(1u, running_browser); |
| 1481 EXPECT_TRUE(item_controller->IsOpen()); | 1517 EXPECT_TRUE(item_controller->IsOpen()); |
| 1482 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 1518 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); |
| 1483 } | 1519 } |
| OLD | NEW |