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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 (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 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 1360
1361 // There should be two items in our launcher by this time. 1361 // There should be two items in our launcher by this time.
1362 EXPECT_EQ(2, model_->item_count()); 1362 EXPECT_EQ(2, model_->item_count());
1363 EXPECT_FALSE(service->IsAppListVisible()); 1363 EXPECT_FALSE(service->IsAppListVisible());
1364 1364
1365 // Open the app list menu and check that the drag and drop host was set. 1365 // Open the app list menu and check that the drag and drop host was set.
1366 gfx::Rect app_list_bounds = 1366 gfx::Rect app_list_bounds =
1367 test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen(); 1367 test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen();
1368 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(), 1368 generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
1369 app_list_bounds.CenterPoint().y()); 1369 app_list_bounds.CenterPoint().y());
1370 MessageLoop::current()->RunUntilIdle(); 1370 base::MessageLoop::current()->RunUntilIdle();
1371 generator.ClickLeftButton(); 1371 generator.ClickLeftButton();
1372 1372
1373 EXPECT_TRUE(service->IsAppListVisible()); 1373 EXPECT_TRUE(service->IsAppListVisible());
1374 app_list::AppsGridView* grid_view = 1374 app_list::AppsGridView* grid_view =
1375 app_list::AppsGridView::GetLastGridViewForTest(); 1375 app_list::AppsGridView::GetLastGridViewForTest();
1376 ASSERT_TRUE(grid_view); 1376 ASSERT_TRUE(grid_view);
1377 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test()); 1377 ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
1378 1378
1379 // There should be 2 items in our application list. 1379 // There should be 2 items in our application list.
1380 const views::ViewModel* vm_grid = grid_view->view_model_for_test(); 1380 const views::ViewModel* vm_grid = grid_view->view_model_for_test();
1381 EXPECT_EQ(2, vm_grid->view_size()); 1381 EXPECT_EQ(2, vm_grid->view_size());
1382 1382
1383 // Test #1: Drag an app list which does not exist yet item into the 1383 // Test #1: Drag an app list which does not exist yet item into the
1384 // launcher. Keeping it dragged, see that a new item gets created. Continuing 1384 // launcher. Keeping it dragged, see that a new item gets created. Continuing
1385 // to drag it out should remove it again. 1385 // to drag it out should remove it again.
1386 1386
1387 // Get over item #1 of the application list and press the mouse button. 1387 // Get over item #1 of the application list and press the mouse button.
1388 views::View* item1 = vm_grid->view_at(1); 1388 views::View* item1 = vm_grid->view_at(1);
1389 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen(); 1389 gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen();
1390 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 1390 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
1391 bounds_grid_1.CenterPoint().y()); 1391 bounds_grid_1.CenterPoint().y());
1392 MessageLoop::current()->RunUntilIdle(); 1392 base::MessageLoop::current()->RunUntilIdle();
1393 generator.PressLeftButton(); 1393 generator.PressLeftButton();
1394 1394
1395 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1395 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1396 1396
1397 // Drag the item into the launcher and check that a new item gets created. 1397 // Drag the item into the launcher and check that a new item gets created.
1398 const views::ViewModel* vm_launcher = 1398 const views::ViewModel* vm_launcher =
1399 test.launcher_view()->view_model_for_test(); 1399 test.launcher_view()->view_model_for_test();
1400 views::View* launcher1 = vm_launcher->view_at(1); 1400 views::View* launcher1 = vm_launcher->view_at(1);
1401 gfx::Rect bounds_launcher_1 = launcher1->GetBoundsInScreen(); 1401 gfx::Rect bounds_launcher_1 = launcher1->GetBoundsInScreen();
1402 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), 1402 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(),
1403 bounds_launcher_1.CenterPoint().y()); 1403 bounds_launcher_1.CenterPoint().y());
1404 MessageLoop::current()->RunUntilIdle(); 1404 base::MessageLoop::current()->RunUntilIdle();
1405 1405
1406 // Check that a new item got created. 1406 // Check that a new item got created.
1407 EXPECT_EQ(3, model_->item_count()); 1407 EXPECT_EQ(3, model_->item_count());
1408 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1408 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1409 1409
1410 // Move it where the item originally was and check that it disappears again. 1410 // Move it where the item originally was and check that it disappears again.
1411 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 1411 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
1412 bounds_grid_1.CenterPoint().y()); 1412 bounds_grid_1.CenterPoint().y());
1413 MessageLoop::current()->RunUntilIdle(); 1413 base::MessageLoop::current()->RunUntilIdle();
1414 EXPECT_EQ(2, model_->item_count()); 1414 EXPECT_EQ(2, model_->item_count());
1415 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1415 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1416 1416
1417 // Dropping it should keep the launcher as it originally was. 1417 // Dropping it should keep the launcher as it originally was.
1418 generator.ReleaseLeftButton(); 1418 generator.ReleaseLeftButton();
1419 MessageLoop::current()->RunUntilIdle(); 1419 base::MessageLoop::current()->RunUntilIdle();
1420 EXPECT_EQ(2, model_->item_count()); 1420 EXPECT_EQ(2, model_->item_count());
1421 // There are a few animations which need finishing before we can continue. 1421 // There are a few animations which need finishing before we can continue.
1422 test.RunMessageLoopUntilAnimationsDone(); 1422 test.RunMessageLoopUntilAnimationsDone();
1423 // Move the mouse outside of the launcher. 1423 // Move the mouse outside of the launcher.
1424 generator.MoveMouseTo(0, 0); 1424 generator.MoveMouseTo(0, 0);
1425 1425
1426 // Test #2: Check that the unknown item dropped into the launcher will 1426 // Test #2: Check that the unknown item dropped into the launcher will
1427 // create a new item. 1427 // create a new item.
1428 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 1428 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
1429 bounds_grid_1.CenterPoint().y()); 1429 bounds_grid_1.CenterPoint().y());
1430 generator.PressLeftButton(); 1430 generator.PressLeftButton();
1431 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), 1431 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(),
1432 bounds_launcher_1.CenterPoint().y()); 1432 bounds_launcher_1.CenterPoint().y());
1433 MessageLoop::current()->RunUntilIdle(); 1433 base::MessageLoop::current()->RunUntilIdle();
1434 EXPECT_EQ(3, model_->item_count()); 1434 EXPECT_EQ(3, model_->item_count());
1435 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1435 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1436 generator.ReleaseLeftButton(); 1436 generator.ReleaseLeftButton();
1437 MessageLoop::current()->RunUntilIdle(); 1437 base::MessageLoop::current()->RunUntilIdle();
1438 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1438 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1439 EXPECT_EQ(3, model_->item_count()); // It should be still there. 1439 EXPECT_EQ(3, model_->item_count()); // It should be still there.
1440 test.RunMessageLoopUntilAnimationsDone(); 1440 test.RunMessageLoopUntilAnimationsDone();
1441 1441
1442 // Test #3: Check that the now known item dropped into the launcher will 1442 // Test #3: Check that the now known item dropped into the launcher will
1443 // not create a new item. 1443 // not create a new item.
1444 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 1444 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
1445 bounds_grid_1.CenterPoint().y()); 1445 bounds_grid_1.CenterPoint().y());
1446 generator.PressLeftButton(); 1446 generator.PressLeftButton();
1447 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(), 1447 generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(),
1448 bounds_launcher_1.CenterPoint().y()); 1448 bounds_launcher_1.CenterPoint().y());
1449 MessageLoop::current()->RunUntilIdle(); 1449 base::MessageLoop::current()->RunUntilIdle();
1450 EXPECT_EQ(3, model_->item_count()); // No new item got added. 1450 EXPECT_EQ(3, model_->item_count()); // No new item got added.
1451 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1451 EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1452 generator.ReleaseLeftButton(); 1452 generator.ReleaseLeftButton();
1453 MessageLoop::current()->RunUntilIdle(); 1453 base::MessageLoop::current()->RunUntilIdle();
1454 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test()); 1454 EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
1455 EXPECT_EQ(3, model_->item_count()); // And it remains that way. 1455 EXPECT_EQ(3, model_->item_count()); // And it remains that way.
1456 } 1456 }
1457 1457
1458 // Check LauncherItemController of Browser Shortcut functionality. 1458 // Check LauncherItemController of Browser Shortcut functionality.
1459 IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTestNoDefaultBrowser, 1459 IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTestNoDefaultBrowser,
1460 BrowserShortcutLauncherItemController) { 1460 BrowserShortcutLauncherItemController) {
1461 ChromeLauncherControllerPerApp* controller = 1461 ChromeLauncherControllerPerApp* controller =
1462 static_cast<ChromeLauncherControllerPerApp*>(launcher_->delegate()); 1462 static_cast<ChromeLauncherControllerPerApp*>(launcher_->delegate());
1463 LauncherItemController* item_controller = 1463 LauncherItemController* item_controller =
(...skipping 17 matching lines...) Expand all
1481 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); 1481 EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
1482 1482
1483 // Activate again. This doesn't create new browser. 1483 // Activate again. This doesn't create new browser.
1484 // It activates window. 1484 // It activates window.
1485 item_controller->Activate(); 1485 item_controller->Activate();
1486 running_browser = chrome::GetTotalBrowserCount(); 1486 running_browser = chrome::GetTotalBrowserCount();
1487 EXPECT_EQ(1u, running_browser); 1487 EXPECT_EQ(1u, running_browser);
1488 EXPECT_TRUE(item_controller->IsOpen()); 1488 EXPECT_TRUE(item_controller->IsOpen());
1489 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 1489 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
1490 } 1490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698