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

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: browsertest: Close windows in other order Created 4 years, 8 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 // Test 1
stevenjb 2016/04/26 16:30:00 Describe what each part of this test is testing fo
Valentin Ilie 2016/04/28 09:40:09 Done.
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 item_count++;
stevenjb 2016/04/26 16:30:00 nit: instead of incrementing item_count here and b
Valentin Ilie 2016/04/28 09:40:09 Done.
1507 EXPECT_EQ(item_count, shelf_model->item_count());
1508 CloseAppWindow(window1);
1509
1510 // Test 2
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 params.show_in_shelf = true;
1517 AppWindow* window2 =
1518 CreateAppWindowFromParams(browser()->profile(), extension, params);
1519 // There should be 2 items added to the shelf: although window1 has
1520 // show_in_shelf set to false, it's the first window created so its icon must
1521 // show up in shelf.
1522 item_count += 2;
1523 EXPECT_EQ(item_count, shelf_model->item_count());
1524 CloseAppWindow(window1);
1525 CloseAppWindow(window2);
1526
1527 // Test 3
1528 item_count = shelf_model->item_count();
1529 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1530
1531 params.show_in_shelf = false;
1532 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1533 // There should be 1 item added to the shelf: although show_in_shelf is false,
1534 // this is the first window created.
1535 item_count++;
1536 EXPECT_EQ(item_count, shelf_model->item_count());
1537 CloseAppWindow(window1);
1538
1539 // Test 4
1540 item_count = shelf_model->item_count();
1541
1542 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1543
1544 params.show_in_shelf = true;
1545 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1546 params.show_in_shelf = false;
1547 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1548 // There should be 1 item added to the shelf.
1549 item_count += 1;
stevenjb 2016/04/26 16:30:00 This seems incorrect. In the second test, 2 items
Valentin Ilie 2016/04/28 09:40:09 We should decide the appropriate behavior here.
1550 EXPECT_EQ(item_count, shelf_model->item_count());
1551 CloseAppWindow(window1);
stevenjb 2016/04/26 16:30:00 We should also test that the shelf item(s) go away
Valentin Ilie 2016/04/28 09:40:09 Done.
1552 CloseAppWindow(window2);
1553
1554 // Test 5
1555 item_count = shelf_model->item_count();
1556
1557 extension = LoadAndLaunchPlatformApp("launch", "Launched");
1558 params.show_in_shelf = false;
1559 window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1560 params.show_in_shelf = false;
1561 window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
1562 params.show_in_shelf = true;
1563 AppWindow* window3 =
1564 CreateAppWindowFromParams(browser()->profile(), extension, params);
1565 params.show_in_shelf = true;
1566 AppWindow* window4 =
1567 CreateAppWindowFromParams(browser()->profile(), extension, params);
1568 // There should be 3 item added to the shelf.
stevenjb 2016/04/26 16:30:00 s/item/items/
Valentin Ilie 2016/04/28 09:40:09 Done.
1569 item_count += 3;
1570 EXPECT_EQ(item_count, shelf_model->item_count());
1571 // Any window close order should be valid
1572 CloseAppWindow(window4);
1573 CloseAppWindow(window1);
1574 CloseAppWindow(window3);
1575 CloseAppWindow(window2);
1576 }
1577
1495 // Checks that the browser Alt "tabbing" is properly done. 1578 // Checks that the browser Alt "tabbing" is properly done.
1496 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, 1579 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser,
1497 AltNumberBrowserTabbing) { 1580 AltNumberBrowserTabbing) {
1498 // Get the number of items in the browser menu. 1581 // Get the number of items in the browser menu.
1499 EXPECT_EQ(0u, chrome::GetTotalBrowserCount()); 1582 EXPECT_EQ(0u, chrome::GetTotalBrowserCount());
1500 // The first activation should create a browser at index 1 (App List @ 0). 1583 // The first activation should create a browser at index 1 (App List @ 0).
1501 shelf_->ActivateShelfItem(1); 1584 shelf_->ActivateShelfItem(1);
1502 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); 1585 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1503 // A second activation should not create a new instance. 1586 // A second activation should not create a new instance.
1504 shelf_->ActivateShelfItem(1); 1587 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); 2315 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0);
2233 2316
2234 // There should be two new browsers. 2317 // There should be two new browsers.
2235 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); 2318 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile()));
2236 2319
2237 // The apps should now be running, with the last opened app active. 2320 // 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); 2321 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status);
2239 EXPECT_EQ(ash::STATUS_ACTIVE, 2322 EXPECT_EQ(ash::STATUS_ACTIVE,
2240 model_->ItemByID(bookmark_app_shelf_id)->status); 2323 model_->ItemByID(bookmark_app_shelf_id)->status);
2241 } 2324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698