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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_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 + Fixes v10 Created 4 years, 5 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
« no previous file with comments | « AUTHORS ('k') | chrome/browser/ui/ash/launcher/extension_app_window_launcher_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc
index d1f4e03c844527081319b8a9aa892fc24f3d50dd..8838e34dfcfc2a1062362a321a6cb735cef700e0 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_browsertest.cc
@@ -1532,6 +1532,117 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowAttentionStatus) {
EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
}
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest,
+ ShowInShelfWindowsWithWindowKeySet) {
+ 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;
+ params.window_key = "window1";
+ 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;
+ params.window_key = "window1";
+ window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ params.show_in_shelf = true;
+ params.window_key = "window2";
+ 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;
+ params.window_key = "window1";
+ 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;
+ params.window_key = "window1";
+ window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count()); // main window
+ params.show_in_shelf = false;
+ params.window_key = "window2";
+ window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 2, shelf_model->item_count());
+ CloseAppWindow(window1);
+ // There should be 1 item added to the shelf as the second window
+ // is set to show_in_shelf false
+ 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;
+ params.window_key = "window1";
+ window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ params.show_in_shelf = false;
+ params.window_key = "window2";
+ window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ params.show_in_shelf = true;
+ params.window_key = "window3";
+ AppWindow* window3 =
+ CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 2, shelf_model->item_count());
+ params.show_in_shelf = true;
+ params.window_key = "window4";
+ 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());
+ // Any window close order should be valid
+ CloseAppWindow(window4);
+ // Closed window4 that was shown in shelf. item_count would decrease
+ EXPECT_EQ(item_count + 2, shelf_model->item_count());
+ CloseAppWindow(window1);
+ // Closed window1 which was grouped together with window2 so item_count
+ // would not decrease
+ EXPECT_EQ(item_count + 2, shelf_model->item_count());
+ CloseAppWindow(window3);
+ // Closed window3 that was shown in shelf. item_count would decrease
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ CloseAppWindow(window2);
+ // Closed window2 - there is no other window in that group and item_count
+ // would decrease
+ EXPECT_EQ(item_count, shelf_model->item_count());
+}
+
// Checks that the browser Alt "tabbing" is properly done.
IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser,
AltNumberBrowserTabbing) {
« no previous file with comments | « AUTHORS ('k') | chrome/browser/ui/ash/launcher/extension_app_window_launcher_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698