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

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

Issue 2716403005: mash: Remove shelf app menu item objects. (Closed)
Patch Set: Address comments. Created 3 years, 9 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_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/common/shelf/app_list_button.h" 9 #include "ash/common/shelf/app_list_button.h"
10 #include "ash/common/shelf/shelf_button.h" 10 #include "ash/common/shelf/shelf_button.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 int item_count = shelf_model()->item_count(); 545 int item_count = shelf_model()->item_count();
546 546
547 // Run the application; a shelf item should be added with one app menu item. 547 // Run the application; a shelf item should be added with one app menu item.
548 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); 548 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched");
549 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension); 549 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension);
550 ASSERT_EQ(item_count + 1, shelf_model()->item_count()); 550 ASSERT_EQ(item_count + 1, shelf_model()->item_count());
551 const ash::ShelfItem& item1 = GetLastLauncherItem(); 551 const ash::ShelfItem& item1 = GetLastLauncherItem();
552 ash::ShelfID item_id = item1.id; 552 ash::ShelfID item_id = item1.id;
553 EXPECT_EQ(ash::TYPE_APP, item1.type); 553 EXPECT_EQ(ash::TYPE_APP, item1.type);
554 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 554 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
555 EXPECT_EQ(1u, controller_->GetAppMenuItems(item1, 0).size()); // 1 window 555 EXPECT_EQ(1u, controller_->GetAppMenuItemsForTesting(item1).size());
556 556
557 // Add a second window; confirm the shelf item stays; check the app menu. 557 // Add a second window; confirm the shelf item stays; check the app menu.
558 AppWindow* window2 = CreateAppWindow(browser()->profile(), extension); 558 AppWindow* window2 = CreateAppWindow(browser()->profile(), extension);
559 ASSERT_EQ(item_count + 1, shelf_model()->item_count()); 559 ASSERT_EQ(item_count + 1, shelf_model()->item_count());
560 const ash::ShelfItem& item2 = *shelf_model()->ItemByID(item_id); 560 const ash::ShelfItem& item2 = *shelf_model()->ItemByID(item_id);
561 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status); 561 EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
562 EXPECT_EQ(2u, controller_->GetAppMenuItems(item2, 0).size()); // 2 windows 562 EXPECT_EQ(2u, controller_->GetAppMenuItemsForTesting(item2).size());
563 563
564 // Close the second window; confirm the shelf item stays; check the app menu. 564 // Close the second window; confirm the shelf item stays; check the app menu.
565 CloseAppWindow(window2); 565 CloseAppWindow(window2);
566 ASSERT_EQ(item_count + 1, shelf_model()->item_count()); 566 ASSERT_EQ(item_count + 1, shelf_model()->item_count());
567 const ash::ShelfItem& item3 = *shelf_model()->ItemByID(item_id); 567 const ash::ShelfItem& item3 = *shelf_model()->ItemByID(item_id);
568 EXPECT_EQ(ash::STATUS_ACTIVE, item3.status); 568 EXPECT_EQ(ash::STATUS_ACTIVE, item3.status);
569 EXPECT_EQ(1u, controller_->GetAppMenuItems(item3, 0).size()); // 1 window 569 EXPECT_EQ(1u, controller_->GetAppMenuItemsForTesting(item3).size());
570 570
571 // Close the first window; the shelf item should be removed. 571 // Close the first window; the shelf item should be removed.
572 CloseAppWindow(window1); 572 CloseAppWindow(window1);
573 ASSERT_EQ(item_count, shelf_model()->item_count()); 573 ASSERT_EQ(item_count, shelf_model()->item_count());
574 } 574 }
575 575
576 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) { 576 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) {
577 int item_count = shelf_model()->item_count(); 577 int item_count = shelf_model()->item_count();
578 578
579 // First run app. 579 // First run app.
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 2394
2395 // Close all windows via the menu item. 2395 // Close all windows via the menu item.
2396 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2396 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2397 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2397 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2398 2398
2399 // Check if "Close" is removed from the context menu. 2399 // Check if "Close" is removed from the context menu.
2400 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); 2400 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu();
2401 ASSERT_FALSE( 2401 ASSERT_FALSE(
2402 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2402 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2403 } 2403 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698