OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 TestEvent click_event(ui::ET_MOUSE_PRESSED); | 1484 TestEvent click_event(ui::ET_MOUSE_PRESSED); |
1485 item_controller->ItemSelected(click_event); | 1485 item_controller->ItemSelected(click_event); |
1486 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); | 1486 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); |
1487 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 1487 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
1488 | 1488 |
1489 // Active windows don't show attention. | 1489 // Active windows don't show attention. |
1490 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); | 1490 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); |
1491 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 1491 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
1492 } | 1492 } |
1493 | 1493 |
| 1494 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, ShowInShelfWindows) { |
| 1495 ash::ShelfModel* shelf_model = ash::Shell::GetInstance()->shelf_model(); |
| 1496 |
| 1497 // Test 1 |
| 1498 int item_count = shelf_model->item_count(); |
| 1499 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 1500 AppWindow::CreateParams params; |
| 1501 params.show_in_shelf = true; |
| 1502 AppWindow* window1 = |
| 1503 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1504 // There should be only 1 item added to the shelf. |
| 1505 item_count++; |
| 1506 EXPECT_EQ(item_count, shelf_model->item_count()); |
| 1507 CloseAppWindow(window1); |
| 1508 |
| 1509 // Test 2 |
| 1510 item_count = shelf_model->item_count(); |
| 1511 extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 1512 |
| 1513 params.show_in_shelf = false; |
| 1514 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1515 params.show_in_shelf = true; |
| 1516 AppWindow* window2 = |
| 1517 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1518 // There should be 2 items added to the shelf: although window1 has |
| 1519 // show_in_shelf set to false, it's the first window created so its icon must |
| 1520 // show up in shelf. |
| 1521 item_count += 2; |
| 1522 EXPECT_EQ(item_count, shelf_model->item_count()); |
| 1523 CloseAppWindow(window1); |
| 1524 CloseAppWindow(window2); |
| 1525 |
| 1526 // Test 3 |
| 1527 item_count = shelf_model->item_count(); |
| 1528 extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 1529 |
| 1530 params.show_in_shelf = false; |
| 1531 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1532 // There should be 1 item added to the shelf: although show_in_shelf is false, |
| 1533 // this is the first window created. |
| 1534 item_count++; |
| 1535 EXPECT_EQ(item_count, shelf_model->item_count()); |
| 1536 CloseAppWindow(window1); |
| 1537 |
| 1538 // Test 4 |
| 1539 item_count = shelf_model->item_count(); |
| 1540 |
| 1541 extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 1542 |
| 1543 params.show_in_shelf = true; |
| 1544 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1545 params.show_in_shelf = false; |
| 1546 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1547 // There should be 1 item added to the shelf. |
| 1548 item_count += 1; |
| 1549 EXPECT_EQ(item_count, shelf_model->item_count()); |
| 1550 CloseAppWindow(window1); |
| 1551 CloseAppWindow(window2); |
| 1552 |
| 1553 // Test 5 |
| 1554 item_count = shelf_model->item_count(); |
| 1555 |
| 1556 extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
| 1557 params.show_in_shelf = false; |
| 1558 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1559 params.show_in_shelf = false; |
| 1560 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1561 params.show_in_shelf = true; |
| 1562 AppWindow* window3 = |
| 1563 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1564 params.show_in_shelf = true; |
| 1565 AppWindow* window4 = |
| 1566 CreateAppWindowFromParams(browser()->profile(), extension, params); |
| 1567 // There should be 3 item added to the shelf. |
| 1568 item_count += 3; |
| 1569 EXPECT_EQ(item_count, shelf_model->item_count()); |
| 1570 CloseAppWindow(window1); |
| 1571 CloseAppWindow(window2); |
| 1572 CloseAppWindow(window3); |
| 1573 CloseAppWindow(window4); |
| 1574 } |
| 1575 |
1494 // Checks that the browser Alt "tabbing" is properly done. | 1576 // Checks that the browser Alt "tabbing" is properly done. |
1495 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, | 1577 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, |
1496 AltNumberBrowserTabbing) { | 1578 AltNumberBrowserTabbing) { |
1497 // Get the number of items in the browser menu. | 1579 // Get the number of items in the browser menu. |
1498 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); | 1580 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); |
1499 // The first activation should create a browser at index 1 (App List @ 0). | 1581 // The first activation should create a browser at index 1 (App List @ 0). |
1500 shelf_->ActivateShelfItem(1); | 1582 shelf_->ActivateShelfItem(1); |
1501 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1583 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1502 // A second activation should not create a new instance. | 1584 // A second activation should not create a new instance. |
1503 shelf_->ActivateShelfItem(1); | 1585 shelf_->ActivateShelfItem(1); |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2316 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
2235 | 2317 |
2236 // There should be two new browsers. | 2318 // There should be two new browsers. |
2237 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); | 2319 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); |
2238 | 2320 |
2239 // The apps should now be running, with the last opened app active. | 2321 // The apps should now be running, with the last opened app active. |
2240 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); | 2322 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); |
2241 EXPECT_EQ(ash::STATUS_ACTIVE, | 2323 EXPECT_EQ(ash::STATUS_ACTIVE, |
2242 model_->ItemByID(bookmark_app_shelf_id)->status); | 2324 model_->ItemByID(bookmark_app_shelf_id)->status); |
2243 } | 2325 } |
OLD | NEW |