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

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

Issue 1914993002: Enhance chrome.app.window API with better shelf integration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase v1 Created 4 years, 7 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 <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 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 TestEvent click_event(ui::ET_MOUSE_PRESSED); 1485 TestEvent click_event(ui::ET_MOUSE_PRESSED);
1486 item_controller->ItemSelected(click_event); 1486 item_controller->ItemSelected(click_event);
1487 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); 1487 EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
1488 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 1488 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
1489 1489
1490 // Active windows don't show attention. 1490 // Active windows don't show attention.
1491 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); 1491 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true);
1492 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); 1492 EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
1493 } 1493 }
1494 1494
1495 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, ShowInShelfWindows) {
1496 ash::ShelfModel* shelf_model = ash::Shell::GetInstance()->shelf_model();
1497
1498 // Add a window with shelf True, close it
1499 int item_count = shelf_model->item_count();
1500 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched");
1501 AppWindow::CreateParams params;
1502 params.show_in_shelf = true;
1503 AppWindow* window1 =
1504 CreateAppWindowFromParams(browser()->profile(), extension, params);
1505 // There should be only 1 item added to the shelf.
1506 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1507 CloseAppWindow(window1);
1508 EXPECT_EQ(item_count, shelf_model->item_count());
1509
1510 // Add a window with false, following one with true
1511 item_count = shelf_model->item_count();
1512 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1513
1514 params.show_in_shelf = false;
1515 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1516 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1517 params.show_in_shelf = true;
1518 AppWindow* window2 =
1519 CreateAppWindowFromParams(browser()->profile(), extension, params);
1520 // There should be 2 items added to the shelf: although window1 has
1521 // show_in_shelf set to false, it's the first window created so its icon must
1522 // show up in shelf.
1523 EXPECT_EQ(item_count + 2, shelf_model->item_count());
1524 CloseAppWindow(window1);
1525 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1526 CloseAppWindow(window2);
1527 EXPECT_EQ(item_count, shelf_model->item_count());
1528
1529 // Open just one window with false
1530 item_count = shelf_model->item_count();
1531 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1532
1533 params.show_in_shelf = false;
1534 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1535 // There should be 1 item added to the shelf: although show_in_shelf is false,
1536 // this is the first window created.
1537 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1538 CloseAppWindow(window1);
1539 EXPECT_EQ(item_count, shelf_model->item_count());
1540
1541 // Add a window with true, following one with false
1542 item_count = shelf_model->item_count();
1543 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1544
1545 params.show_in_shelf = true;
1546 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1547 EXPECT_EQ(item_count + 1, shelf_model->item_count()); // main window
1548 params.show_in_shelf = false;
1549 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1550 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1551 // There should be 1 item added to the shelf as the second window
1552 // is set to show_in_shelf false
stevenjb 2016/05/03 20:39:49 This comment should be above the EXPECT
Andra Paraschiv 2016/05/04 11:59:09 Done.
1553 CloseAppWindow(window1);
1554 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1555 CloseAppWindow(window2);
1556 EXPECT_EQ(item_count, shelf_model->item_count());
1557
1558 // Test closing windows in different order
1559 item_count = shelf_model->item_count();
1560
1561 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1562 params.show_in_shelf = false;
1563 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1564 params.show_in_shelf = false;
1565 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1566 params.show_in_shelf = true;
1567 AppWindow* window3 =
1568 CreateAppWindowFromParams(browser()->profile(), extension, params);
1569 params.show_in_shelf = true;
1570 AppWindow* window4 =
1571 CreateAppWindowFromParams(browser()->profile(), extension, params);
1572 // There should be 3 items added to the shelf.
1573 EXPECT_EQ(item_count + 3, shelf_model->item_count());
stevenjb 2016/05/03 20:39:49 I think we should have an EXPECT for each Create h
Andra Paraschiv 2016/05/04 11:59:09 Done.
1574 // Any window close order should be valid
1575 CloseAppWindow(window4);
1576 EXPECT_EQ(item_count + 2, shelf_model->item_count());
stevenjb 2016/05/03 20:39:48 I also think each of these merits an explanation s
Andra Paraschiv 2016/05/04 11:59:09 Done.
1577 CloseAppWindow(window1);
1578 EXPECT_EQ(item_count + 2, shelf_model->item_count());
1579 CloseAppWindow(window3);
1580 EXPECT_EQ(item_count + 1, shelf_model->item_count());
1581 CloseAppWindow(window2);
1582 EXPECT_EQ(item_count, shelf_model->item_count());
1583 }
1584
1495 // Checks that the browser Alt "tabbing" is properly done. 1585 // Checks that the browser Alt "tabbing" is properly done.
1496 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, 1586 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser,
1497 AltNumberBrowserTabbing) { 1587 AltNumberBrowserTabbing) {
1498 // Get the number of items in the browser menu. 1588 // Get the number of items in the browser menu.
1499 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); 1589 EXPECT_EQ(0u, chrome::GetTotalBrowserCount());
1500 // The first activation should create a browser at index 1 (App List @ 0). 1590 // The first activation should create a browser at index 1 (App List @ 0).
1501 shelf_->ActivateShelfItem(1); 1591 shelf_->ActivateShelfItem(1);
1502 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 1592 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1503 // A second activation should not create a new instance. 1593 // A second activation should not create a new instance.
1504 shelf_->ActivateShelfItem(1); 1594 shelf_->ActivateShelfItem(1);
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); 2322 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0);
2233 2323
2234 // There should be two new browsers. 2324 // There should be two new browsers.
2235 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); 2325 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile()));
2236 2326
2237 // The apps should now be running, with the last opened app active. 2327 // The apps should now be running, with the last opened app active.
2238 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); 2328 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status);
2239 EXPECT_EQ(ash::STATUS_ACTIVE, 2329 EXPECT_EQ(ash::STATUS_ACTIVE,
2240 model_->ItemByID(bookmark_app_shelf_id)->status); 2330 model_->ItemByID(bookmark_app_shelf_id)->status);
2241 } 2331 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698