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

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 Created 4 years, 6 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_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 eb31c5cb92d9fdabcfb3b5becd4d686c15f1d0f3..4fbc3674a7e78423dfe008f7cd941020191d61db 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
@@ -1530,6 +1530,210 @@ 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();
+
+ //Tests without window_key parameter set
+
+ // 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 + 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;
+ window1 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ params.show_in_shelf = false;
+ window2 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 1, shelf_model->item_count());
+ params.show_in_shelf = true;
+ AppWindow* window3 =
+ CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 2, shelf_model->item_count());
+ 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());
+ // 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());
+
+
+ //Tests with window_key parameter set
+
+ // Add a window with shelf True, close it
+ 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);
+ // 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";
+ 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";
+ window3 = CreateAppWindowFromParams(browser()->profile(), extension, params);
+ EXPECT_EQ(item_count + 2, shelf_model->item_count());
+ params.show_in_shelf = true;
+ params.window_key = "window4";
+ 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());
+}
stevenjb 2016/06/14 18:33:21 This needs to be broken up
Andra Paraschiv 2016/06/28 07:04:46 Done.
+
// 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