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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
index 057118dc8a2eacb50f522d1d79c84302611d937c..97ea5fa9ee7678f4fe2ca212b317b6c21252d62f 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
@@ -1492,6 +1492,96 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowAttentionStatus) {
EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
}
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, ShowInShelfWindows) {
+ ash::ShelfModel* shelf_model = ash::Shell::GetInstance()->shelf_model();
+
+ // Add a window with shelf True, close it
+ int item_count = shelf_model->item_count();
+ const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched");
+ AppWindow::CreateParams params;
+ params.show_in_shelf = true;
+ AppWindow* window1 =
+ CreateAppWindowFromParams(browser()->profile(), extension, params);
+ // There should be only 1 item added to the shelf.
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ CloseAppWindow(window1);
+ EXPECT_EQ(item_count, shelf_model->item_count());
+
+ // Add a window with false, following one with true
+ item_count = shelf_model->item_count();
+ extension = LoadAndLaunchPlatformApp("launch", "Launched");
+
+ params.show_in_shelf = false;
+ window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ params.show_in_shelf = true;
+ AppWindow* window2 =
+ CreateAppWindowFromParams(browser()->profile(), extension, params);
+ // There should be 2 items added to the shelf: although window1 has
+ // show_in_shelf set to false, it's the first window created so its icon must
+ // show up in shelf.
+ EXPECT_EQ(item_count + 2, shelf_model->item_count());
+ CloseAppWindow(window1);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ CloseAppWindow(window2);
+ EXPECT_EQ(item_count, shelf_model->item_count());
+
+ // Open just one window with false
+ item_count = shelf_model->item_count();
+ extension = LoadAndLaunchPlatformApp("launch", "Launched");
+
+ params.show_in_shelf = false;
+ window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ // There should be 1 item added to the shelf: although show_in_shelf is false,
+ // this is the first window created.
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ CloseAppWindow(window1);
+ EXPECT_EQ(item_count, shelf_model->item_count());
+
+ // Add a window with true, following one with false
+ item_count = shelf_model->item_count();
+ extension = LoadAndLaunchPlatformApp("launch", "Launched");
+
+ params.show_in_shelf = true;
+ window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count()); // main window
+ params.show_in_shelf = false;
+ window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ // There should be 1 item added to the shelf as the second window
+ // 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.
+ CloseAppWindow(window1);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ CloseAppWindow(window2);
+ EXPECT_EQ(item_count, shelf_model->item_count());
+
+ // Test closing windows in different order
+ item_count = shelf_model->item_count();
+
+ extension = LoadAndLaunchPlatformApp("launch", "Launched");
+ params.show_in_shelf = false;
+ window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ params.show_in_shelf = false;
+ window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ params.show_in_shelf = true;
+ AppWindow* window3 =
+ CreateAppWindowFromParams(browser()->profile(), extension, params);
+ params.show_in_shelf = true;
+ AppWindow* window4 =
+ CreateAppWindowFromParams(browser()->profile(), extension, params);
+ // There should be 3 items added to the shelf.
+ 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.
+ // Any window close order should be valid
+ CloseAppWindow(window4);
+ 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.
+ CloseAppWindow(window1);
+ EXPECT_EQ(item_count + 2, shelf_model->item_count());
+ CloseAppWindow(window3);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ CloseAppWindow(window2);
+ EXPECT_EQ(item_count, shelf_model->item_count());
+}
+
// Checks that the browser Alt "tabbing" is properly done.
IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser,
AltNumberBrowserTabbing) {

Powered by Google App Engine
This is Rietveld 408576698