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

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

Issue 2791803002: mash: Move LauncherItemController to ash, rename ShelfItemDelegate. (Closed)
Patch Set: Sync and rebase. Created 3 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_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"
11 #include "ash/common/shelf/shelf_constants.h" 11 #include "ash/common/shelf/shelf_constants.h"
12 #include "ash/common/shelf/shelf_model.h" 12 #include "ash/common/shelf/shelf_model.h"
13 #include "ash/common/shelf/shelf_view.h" 13 #include "ash/common/shelf/shelf_view.h"
14 #include "ash/common/shelf/shelf_widget.h" 14 #include "ash/common/shelf/shelf_widget.h"
15 #include "ash/common/shelf/wm_shelf.h" 15 #include "ash/common/shelf/wm_shelf.h"
16 #include "ash/common/wm/window_state.h" 16 #include "ash/common/wm/window_state.h"
17 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
18 #include "ash/common/wm_window.h" 18 #include "ash/common/wm_window.h"
19 #include "ash/public/cpp/app_launch_id.h" 19 #include "ash/public/cpp/app_launch_id.h"
20 #include "ash/public/cpp/shelf_item_delegate.h"
20 #include "ash/public/cpp/window_properties.h" 21 #include "ash/public/cpp/window_properties.h"
21 #include "ash/shell.h" 22 #include "ash/shell.h"
22 #include "ash/test/shelf_view_test_api.h" 23 #include "ash/test/shelf_view_test_api.h"
23 #include "ash/wm/window_properties.h" 24 #include "ash/wm/window_properties.h"
24 #include "ash/wm/window_state_aura.h" 25 #include "ash/wm/window_state_aura.h"
25 #include "ash/wm/window_util.h" 26 #include "ash/wm/window_util.h"
26 #include "base/macros.h" 27 #include "base/macros.h"
27 #include "base/run_loop.h" 28 #include "base/run_loop.h"
28 #include "base/strings/stringprintf.h" 29 #include "base/strings/stringprintf.h"
29 #include "base/strings/utf_string_conversions.h" 30 #include "base/strings/utf_string_conversions.h"
30 #include "build/build_config.h" 31 #include "build/build_config.h"
31 #include "chrome/browser/apps/app_browsertest_util.h" 32 #include "chrome/browser/apps/app_browsertest_util.h"
32 #include "chrome/browser/chrome_notification_types.h" 33 #include "chrome/browser/chrome_notification_types.h"
33 #include "chrome/browser/extensions/extension_apitest.h" 34 #include "chrome/browser/extensions/extension_apitest.h"
34 #include "chrome/browser/extensions/extension_browsertest.h" 35 #include "chrome/browser/extensions/extension_browsertest.h"
35 #include "chrome/browser/extensions/extension_function_test_utils.h" 36 #include "chrome/browser/extensions/extension_function_test_utils.h"
36 #include "chrome/browser/extensions/extension_service.h" 37 #include "chrome/browser/extensions/extension_service.h"
37 #include "chrome/browser/extensions/launch_util.h" 38 #include "chrome/browser/extensions/launch_util.h"
38 #include "chrome/browser/profiles/profile.h" 39 #include "chrome/browser/profiles/profile.h"
39 #include "chrome/browser/ui/app_list/app_list_service.h" 40 #include "chrome/browser/ui/app_list/app_list_service.h"
40 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h" 41 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h"
41 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" 42 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h"
42 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 43 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
43 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h" 44 #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
44 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
45 #include "chrome/browser/ui/ash/session_controller_client.h" 45 #include "chrome/browser/ui/ash/session_controller_client.h"
46 #include "chrome/browser/ui/browser.h" 46 #include "chrome/browser/ui/browser.h"
47 #include "chrome/browser/ui/browser_commands.h" 47 #include "chrome/browser/ui/browser_commands.h"
48 #include "chrome/browser/ui/browser_finder.h" 48 #include "chrome/browser/ui/browser_finder.h"
49 #include "chrome/browser/ui/browser_list.h" 49 #include "chrome/browser/ui/browser_list.h"
50 #include "chrome/browser/ui/browser_window.h" 50 #include "chrome/browser/ui/browser_window.h"
51 #include "chrome/browser/ui/chrome_pages.h" 51 #include "chrome/browser/ui/chrome_pages.h"
52 #include "chrome/browser/ui/extensions/app_launch_params.h" 52 #include "chrome/browser/ui/extensions/app_launch_params.h"
53 #include "chrome/browser/ui/extensions/application_launch.h" 53 #include "chrome/browser/ui/extensions/application_launch.h"
54 #include "chrome/browser/ui/settings_window_manager.h" 54 #include "chrome/browser/ui/settings_window_manager.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 ChromeLauncherControllerImpl* GetChromeLauncherControllerImpl() { 93 ChromeLauncherControllerImpl* GetChromeLauncherControllerImpl() {
94 return static_cast<ChromeLauncherControllerImpl*>( 94 return static_cast<ChromeLauncherControllerImpl*>(
95 ChromeLauncherController::instance()); 95 ChromeLauncherController::instance());
96 } 96 }
97 97
98 // A callback that records the action taken when a shelf item is selected. 98 // A callback that records the action taken when a shelf item is selected.
99 void SelectItemCallback(ash::ShelfAction* action_taken, 99 void SelectItemCallback(ash::ShelfAction* action_taken,
100 base::RunLoop* run_loop, 100 base::RunLoop* run_loop,
101 ash::ShelfAction action, 101 ash::ShelfAction action,
102 base::Optional<MenuItemList>) { 102 base::Optional<ash::MenuItemList>) {
103 *action_taken = action; 103 *action_taken = action;
104 run_loop->Quit(); 104 run_loop->Quit();
105 } 105 }
106 106
107 // Calls ShelfItemDelegate::SelectItem with an event type and default arguments. 107 // Calls ShelfItemDelegate::SelectItem with an event type and default arguments.
108 ash::ShelfAction SelectItem(ash::mojom::ShelfItemDelegate* delegate, 108 ash::ShelfAction SelectItem(ash::ShelfItemDelegate* delegate,
109 ui::EventType event_type) { 109 ui::EventType event_type) {
110 std::unique_ptr<ui::Event> event; 110 std::unique_ptr<ui::Event> event;
111 if (event_type == ui::ET_MOUSE_PRESSED) { 111 if (event_type == ui::ET_MOUSE_PRESSED) {
112 event = 112 event =
113 base::MakeUnique<ui::MouseEvent>(event_type, gfx::Point(), gfx::Point(), 113 base::MakeUnique<ui::MouseEvent>(event_type, gfx::Point(), gfx::Point(),
114 ui::EventTimeForNow(), ui::EF_NONE, 0); 114 ui::EventTimeForNow(), ui::EF_NONE, 0);
115 } else if (event_type == ui::ET_KEY_RELEASED) { 115 } else if (event_type == ui::ET_KEY_RELEASED) {
116 event = base::MakeUnique<ui::KeyEvent>(event_type, ui::VKEY_UNKNOWN, 116 event = base::MakeUnique<ui::KeyEvent>(event_type, ui::VKEY_UNKNOWN,
117 ui::EF_NONE); 117 ui::EF_NONE);
118 } 118 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // the desired item. 246 // the desired item.
247 return shelf_model()->items()[shelf_model()->item_count() - 1]; 247 return shelf_model()->items()[shelf_model()->item_count() - 1];
248 } 248 }
249 249
250 const ash::ShelfItem& GetLastLauncherPanelItem() { 250 const ash::ShelfItem& GetLastLauncherPanelItem() {
251 // Panels show up on the right side of the shelf, so the desired item 251 // Panels show up on the right side of the shelf, so the desired item
252 // will be the last one. 252 // will be the last one.
253 return shelf_model()->items()[shelf_model()->item_count() - 1]; 253 return shelf_model()->items()[shelf_model()->item_count() - 1];
254 } 254 }
255 255
256 LauncherItemController* GetItemController(ash::ShelfID id) { 256 ash::ShelfItemDelegate* GetShelfItemDelegate(ash::ShelfID id) {
257 return controller_->GetLauncherItemController(id); 257 return controller_->GetShelfItemDelegate(id);
258 } 258 }
259 259
260 ChromeLauncherControllerImpl* controller_; 260 ChromeLauncherControllerImpl* controller_;
261 261
262 private: 262 private:
263 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest); 263 DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest);
264 }; 264 };
265 265
266 enum RipOffCommand { 266 enum RipOffCommand {
267 // Drag the item off the shelf and let the mouse go. 267 // Drag the item off the shelf and let the mouse go.
(...skipping 19 matching lines...) Expand all
287 287
288 shelf_ = 288 shelf_ =
289 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); 289 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow());
290 model_ = ash::Shell::Get()->shelf_model(); 290 model_ = ash::Shell::Get()->shelf_model();
291 controller_ = GetChromeLauncherControllerImpl(); 291 controller_ = GetChromeLauncherControllerImpl();
292 ASSERT_TRUE(controller_); 292 ASSERT_TRUE(controller_);
293 return ExtensionBrowserTest::RunTestOnMainThreadLoop(); 293 return ExtensionBrowserTest::RunTestOnMainThreadLoop();
294 } 294 }
295 295
296 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) { 296 size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) {
297 LauncherItemController* item_controller = 297 ash::ShelfItemDelegate* item_controller =
298 controller_->GetBrowserShortcutLauncherItemController(); 298 controller_->GetBrowserShortcutLauncherItemController();
299 return item_controller 299 return item_controller
300 ->GetAppMenuItems(show_all_tabs ? ui::EF_SHIFT_DOWN : 0) 300 ->GetAppMenuItems(show_all_tabs ? ui::EF_SHIFT_DOWN : 0)
301 .size(); 301 .size();
302 } 302 }
303 303
304 const Extension* LoadAndLaunchExtension( 304 const Extension* LoadAndLaunchExtension(
305 const char* name, 305 const char* name,
306 extensions::LaunchContainer container, 306 extensions::LaunchContainer container,
307 WindowOpenDisposition disposition) { 307 WindowOpenDisposition disposition) {
308 EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name))); 308 EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name)));
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, 717 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest,
718 PackagedAppClickBehaviorInMinimizeMode) { 718 PackagedAppClickBehaviorInMinimizeMode) {
719 // Launch one platform app and create a window for it. 719 // Launch one platform app and create a window for it.
720 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); 720 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched");
721 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension1); 721 AppWindow* window1 = CreateAppWindow(browser()->profile(), extension1);
722 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 722 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
723 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 723 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
724 724
725 // Confirm that a controller item was created and is the correct state. 725 // Confirm that a controller item was created and is the correct state.
726 const ash::ShelfItem& item1 = GetLastLauncherItem(); 726 const ash::ShelfItem& item1 = GetLastLauncherItem();
727 LauncherItemController* item1_controller = GetItemController(item1.id); 727 ash::ShelfItemDelegate* item1_delegate = GetShelfItemDelegate(item1.id);
728 EXPECT_EQ(ash::TYPE_APP, item1.type); 728 EXPECT_EQ(ash::TYPE_APP, item1.type);
729 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 729 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
730 // Since it is already active, clicking it should minimize. 730 // Since it is already active, clicking it should minimize.
731 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); 731 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
732 EXPECT_FALSE(window1->GetNativeWindow()->IsVisible()); 732 EXPECT_FALSE(window1->GetNativeWindow()->IsVisible());
733 EXPECT_FALSE(window1->GetBaseWindow()->IsActive()); 733 EXPECT_FALSE(window1->GetBaseWindow()->IsActive());
734 EXPECT_TRUE(window1->GetBaseWindow()->IsMinimized()); 734 EXPECT_TRUE(window1->GetBaseWindow()->IsMinimized());
735 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); 735 EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
736 // Clicking the item again should activate the window again. 736 // Clicking the item again should activate the window again.
737 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); 737 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
738 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 738 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
739 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 739 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
740 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 740 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
741 // Maximizing a window should preserve state after minimize + click. 741 // Maximizing a window should preserve state after minimize + click.
742 window1->GetBaseWindow()->Maximize(); 742 window1->GetBaseWindow()->Maximize();
743 window1->GetBaseWindow()->Minimize(); 743 window1->GetBaseWindow()->Minimize();
744 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); 744 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
745 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 745 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
746 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 746 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
747 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); 747 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized());
748 window1->GetBaseWindow()->Restore(); 748 window1->GetBaseWindow()->Restore();
749 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 749 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
750 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 750 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
751 EXPECT_FALSE(window1->GetBaseWindow()->IsMaximized()); 751 EXPECT_FALSE(window1->GetBaseWindow()->IsMaximized());
752 752
753 // Creating a second window of the same type should change the behavior so 753 // Creating a second window of the same type should change the behavior so
754 // that a click does not change the activation state. 754 // that a click does not change the activation state.
755 AppWindow* window1a = CreateAppWindow(browser()->profile(), extension1); 755 AppWindow* window1a = CreateAppWindow(browser()->profile(), extension1);
756 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); 756 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
757 EXPECT_TRUE(window1a->GetBaseWindow()->IsActive()); 757 EXPECT_TRUE(window1a->GetBaseWindow()->IsActive());
758 // The first click does nothing. 758 // The first click does nothing.
759 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); 759 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
760 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 760 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
761 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); 761 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
762 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 762 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
763 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); 763 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive());
764 // The second neither. 764 // The second neither.
765 SelectItem(item1_controller, ui::ET_MOUSE_PRESSED); 765 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
766 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); 766 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
767 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible()); 767 EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
768 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); 768 EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
769 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive()); 769 EXPECT_FALSE(window1a->GetBaseWindow()->IsActive());
770 } 770 }
771 771
772 // Confirm that ash::ShelfWindowWatcher correctly handles app panels. 772 // Confirm that ash::ShelfWindowWatcher correctly handles app panels.
773 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanel) { 773 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanel) {
774 // Enable experimental APIs to allow panel creation. 774 // Enable experimental APIs to allow panel creation.
775 base::CommandLine::ForCurrentProcess()->AppendSwitch( 775 base::CommandLine::ForCurrentProcess()->AppendSwitch(
776 extensions::switches::kEnableExperimentalExtensionApis); 776 extensions::switches::kEnableExperimentalExtensionApis);
777 // Launch a platform app and create a panel window for it. 777 // Launch a platform app and create a panel window for it.
778 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); 778 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched");
779 AppWindow::CreateParams params; 779 AppWindow::CreateParams params;
780 params.window_type = AppWindow::WINDOW_TYPE_PANEL; 780 params.window_type = AppWindow::WINDOW_TYPE_PANEL;
781 params.focused = false; 781 params.focused = false;
782 AppWindow* panel = 782 AppWindow* panel =
783 CreateAppWindowFromParams(browser()->profile(), extension1, params); 783 CreateAppWindowFromParams(browser()->profile(), extension1, params);
784 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); 784 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
785 // Panels should not be active by default. 785 // Panels should not be active by default.
786 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); 786 EXPECT_FALSE(panel->GetBaseWindow()->IsActive());
787 // Confirm that an item delegate was created and is in the correct state. 787 // Confirm that an item delegate was created and is in the correct state.
788 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); 788 const ash::ShelfItem& item1 = GetLastLauncherPanelItem();
789 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); 789 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type);
790 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); 790 EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
791 EXPECT_EQ(nullptr, GetItemController(item1.id)); 791 EXPECT_EQ(nullptr, GetShelfItemDelegate(item1.id));
792 ash::mojom::ShelfItemDelegate* item1_delegate = 792 ash::ShelfItemDelegate* item1_delegate =
793 shelf_model()->GetShelfItemDelegate(item1.id); 793 shelf_model()->GetShelfItemDelegate(item1.id);
794 EXPECT_EQ(ash::TYPE_APP_PANEL, 794 EXPECT_EQ(ash::TYPE_APP_PANEL,
795 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); 795 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey));
796 // Click the item and confirm that the panel is activated. 796 // Click the item and confirm that the panel is activated.
797 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); 797 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
798 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); 798 EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
799 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 799 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
800 // Click the item again and confirm that the panel is minimized. 800 // Click the item again and confirm that the panel is minimized.
801 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); 801 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
802 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); 802 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized());
(...skipping 18 matching lines...) Expand all
821 params.focused = false; 821 params.focused = false;
822 AppWindow* panel = 822 AppWindow* panel =
823 CreateAppWindowFromParams(browser()->profile(), extension1, params); 823 CreateAppWindowFromParams(browser()->profile(), extension1, params);
824 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); 824 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
825 // Panels should not be active by default. 825 // Panels should not be active by default.
826 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); 826 EXPECT_FALSE(panel->GetBaseWindow()->IsActive());
827 // Confirm that an item delegate was created and is in the correct state. 827 // Confirm that an item delegate was created and is in the correct state.
828 const ash::ShelfItem& item1 = GetLastLauncherPanelItem(); 828 const ash::ShelfItem& item1 = GetLastLauncherPanelItem();
829 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type); 829 EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type);
830 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); 830 EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
831 EXPECT_EQ(nullptr, GetItemController(item1.id)); 831 EXPECT_EQ(nullptr, GetShelfItemDelegate(item1.id));
832 ash::mojom::ShelfItemDelegate* item1_delegate = 832 ash::ShelfItemDelegate* item1_delegate =
833 shelf_model()->GetShelfItemDelegate(item1.id); 833 shelf_model()->GetShelfItemDelegate(item1.id);
834 EXPECT_EQ(ash::TYPE_APP_PANEL, 834 EXPECT_EQ(ash::TYPE_APP_PANEL,
835 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey)); 835 panel->GetNativeWindow()->GetProperty(ash::kShelfItemTypeKey));
836 // Click the item and confirm that the panel is activated. 836 // Click the item and confirm that the panel is activated.
837 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); 837 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
838 EXPECT_TRUE(panel->GetBaseWindow()->IsActive()); 838 EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
839 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); 839 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
840 // Click the item again and confirm that the panel is minimized. 840 // Click the item again and confirm that the panel is minimized.
841 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED); 841 SelectItem(item1_delegate, ui::ET_MOUSE_PRESSED);
842 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized()); 842 EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 // This test creates one app window and one panel window. 889 // This test creates one app window and one panel window.
890 int shelf_item_count = shelf_model()->item_count(); 890 int shelf_item_count = shelf_model()->item_count();
891 ASSERT_EQ(base_shelf_item_count + 2, shelf_item_count); 891 ASSERT_EQ(base_shelf_item_count + 2, shelf_item_count);
892 // The Panel will be the last item, the app second-to-last. 892 // The Panel will be the last item, the app second-to-last.
893 const ash::ShelfItem& app_item = 893 const ash::ShelfItem& app_item =
894 shelf_model()->items()[shelf_item_count - 2]; 894 shelf_model()->items()[shelf_item_count - 2];
895 const ash::ShelfItem& panel_item = 895 const ash::ShelfItem& panel_item =
896 shelf_model()->items()[shelf_item_count - 1]; 896 shelf_model()->items()[shelf_item_count - 1];
897 // Icons for Apps are set by the AppWindowLauncherController, so 897 // Icons for Apps are set by the AppWindowLauncherController, so
898 // image_set_by_controller() should be set. 898 // image_set_by_controller() should be set.
899 const LauncherItemController* app_item_controller = 899 const ash::ShelfItemDelegate* app_item_delegate =
900 GetItemController(app_item.id); 900 GetShelfItemDelegate(app_item.id);
901 EXPECT_TRUE(app_item_controller->image_set_by_controller()); 901 EXPECT_TRUE(app_item_delegate->image_set_by_controller());
902 // Panels are handled by ShelfWindowWatcher, not ChromeLauncherController. 902 // Panels are handled by ShelfWindowWatcher, not ChromeLauncherController.
903 EXPECT_EQ(nullptr, GetItemController(panel_item.id)); 903 EXPECT_EQ(nullptr, GetShelfItemDelegate(panel_item.id));
904 // Ensure icon heights are correct (see test.js in app_icon/ test directory) 904 // Ensure icon heights are correct (see test.js in app_icon/ test directory)
905 EXPECT_EQ(ash::GetShelfConstant(ash::SHELF_SIZE), app_item.image.height()); 905 EXPECT_EQ(ash::GetShelfConstant(ash::SHELF_SIZE), app_item.image.height());
906 EXPECT_EQ(64, panel_item.image.height()); 906 EXPECT_EQ(64, panel_item.image.height());
907 } 907 }
908 908
909 // Test that we can launch an app with a shortcut. 909 // Test that we can launch an app with a shortcut.
910 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchPinned) { 910 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTest, LaunchPinned) {
911 TabStripModel* tab_strip = browser()->tab_strip_model(); 911 TabStripModel* tab_strip = browser()->tab_strip_model();
912 int tab_count = tab_strip->count(); 912 int tab_count = tab_strip->count();
913 ash::ShelfID shortcut_id = CreateShortcut("app1"); 913 ash::ShelfID shortcut_id = CreateShortcut("app1");
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 params.window_type = AppWindow::WINDOW_TYPE_PANEL; 1527 params.window_type = AppWindow::WINDOW_TYPE_PANEL;
1528 params.focused = false; 1528 params.focused = false;
1529 AppWindow* panel = 1529 AppWindow* panel =
1530 CreateAppWindowFromParams(browser()->profile(), extension, params); 1530 CreateAppWindowFromParams(browser()->profile(), extension, params);
1531 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible()); 1531 EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
1532 // Panels should not be active by default. 1532 // Panels should not be active by default.
1533 EXPECT_FALSE(panel->GetBaseWindow()->IsActive()); 1533 EXPECT_FALSE(panel->GetBaseWindow()->IsActive());
1534 // Confirm that a shelf item was created and is the correct state. 1534 // Confirm that a shelf item was created and is the correct state.
1535 const ash::ShelfItem& item = GetLastLauncherPanelItem(); 1535 const ash::ShelfItem& item = GetLastLauncherPanelItem();
1536 // Panels are handled by ShelfWindowWatcher, not ChromeLauncherController. 1536 // Panels are handled by ShelfWindowWatcher, not ChromeLauncherController.
1537 EXPECT_EQ(nullptr, GetItemController(item.id)); 1537 EXPECT_EQ(nullptr, GetShelfItemDelegate(item.id));
1538 ash::mojom::ShelfItemDelegate* shelf_item_delegate = 1538 ash::ShelfItemDelegate* shelf_item_delegate =
1539 shelf_model()->GetShelfItemDelegate(item.id); 1539 shelf_model()->GetShelfItemDelegate(item.id);
1540 EXPECT_NE(nullptr, shelf_item_delegate); 1540 EXPECT_NE(nullptr, shelf_item_delegate);
1541 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type); 1541 EXPECT_EQ(ash::TYPE_APP_PANEL, item.type);
1542 EXPECT_EQ(ash::STATUS_RUNNING, item.status); 1542 EXPECT_EQ(ash::STATUS_RUNNING, item.status);
1543 1543
1544 // App windows should go to attention state. 1544 // App windows should go to attention state.
1545 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true); 1545 panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true);
1546 EXPECT_EQ(ash::STATUS_ATTENTION, item.status); 1546 EXPECT_EQ(ash::STATUS_ATTENTION, item.status);
1547 1547
1548 // Click the item and confirm that the panel is activated. 1548 // Click the item and confirm that the panel is activated.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), 1753 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()),
1754 browser()); 1754 browser());
1755 // Check that the LRU browser list does only contain the original browser. 1755 // Check that the LRU browser list does only contain the original browser.
1756 BrowserList* browser_list = BrowserList::GetInstance(); 1756 BrowserList* browser_list = BrowserList::GetInstance();
1757 BrowserList::const_reverse_iterator it = browser_list->begin_last_active(); 1757 BrowserList::const_reverse_iterator it = browser_list->begin_last_active();
1758 EXPECT_EQ(*it, browser()); 1758 EXPECT_EQ(*it, browser());
1759 ++it; 1759 ++it;
1760 EXPECT_EQ(it, browser_list->end_last_active()); 1760 EXPECT_EQ(it, browser_list->end_last_active());
1761 1761
1762 // Now request to either activate an existing app or create a new one. 1762 // Now request to either activate an existing app or create a new one.
1763 LauncherItemController* item_controller = 1763 ash::ShelfItemDelegate* item_delegate =
1764 controller_->GetLauncherItemController(shortcut_id); 1764 controller_->GetShelfItemDelegate(shortcut_id);
1765 SelectItem(item_controller, ui::ET_KEY_RELEASED); 1765 SelectItem(item_delegate, ui::ET_KEY_RELEASED);
1766 1766
1767 // Check that we have set focus on the existing application and nothing new 1767 // Check that we have set focus on the existing application and nothing new
1768 // was created. 1768 // was created.
1769 EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); 1769 EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
1770 EXPECT_EQ(tab_count1, tab_strip->count()); 1770 EXPECT_EQ(tab_count1, tab_strip->count());
1771 EXPECT_EQ(tab_count2, tab_strip2->count()); 1771 EXPECT_EQ(tab_count2, tab_strip2->count());
1772 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()), 1772 EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()),
1773 browser2); 1773 browser2);
1774 } 1774 }
1775 1775
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 // Test now that a click does create a new application tab. 2125 // Test now that a click does create a new application tab.
2126 TabStripModel* tab_strip = browser()->tab_strip_model(); 2126 TabStripModel* tab_strip = browser()->tab_strip_model();
2127 int tab_count = tab_strip->count(); 2127 int tab_count = tab_strip->count();
2128 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(), 2128 generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
2129 bounds_grid_1.CenterPoint().y()); 2129 bounds_grid_1.CenterPoint().y());
2130 generator.ClickLeftButton(); 2130 generator.ClickLeftButton();
2131 base::RunLoop().RunUntilIdle(); 2131 base::RunLoop().RunUntilIdle();
2132 EXPECT_EQ(tab_count + 1, tab_strip->count()); 2132 EXPECT_EQ(tab_count + 1, tab_strip->count());
2133 } 2133 }
2134 2134
2135 // Check LauncherItemController of Browser Shortcut functionality. 2135 // Check ash::ShelfItemDelegate of Browser Shortcut functionality.
2136 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser, 2136 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserTestNoDefaultBrowser,
2137 BrowserShortcutLauncherItemController) { 2137 BrowserShortcutLauncherItemController) {
2138 LauncherItemController* item_controller = 2138 ash::ShelfItemDelegate* item_controller =
2139 controller_->GetBrowserShortcutLauncherItemController(); 2139 controller_->GetBrowserShortcutLauncherItemController();
2140 const ash::ShelfID id = item_controller->shelf_id(); 2140 const ash::ShelfID id = item_controller->shelf_id();
2141 EXPECT_NE(ash::kInvalidShelfID, id); 2141 EXPECT_NE(ash::kInvalidShelfID, id);
2142 2142
2143 // Get the number of browsers. 2143 // Get the number of browsers.
2144 size_t running_browser = chrome::GetTotalBrowserCount(); 2144 size_t running_browser = chrome::GetTotalBrowserCount();
2145 EXPECT_EQ(0u, running_browser); 2145 EXPECT_EQ(0u, running_browser);
2146 EXPECT_FALSE(controller_->IsOpen(id)); 2146 EXPECT_FALSE(controller_->IsOpen(id));
2147 2147
2148 // Activate. This creates new browser 2148 // Activate. This creates new browser
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 2406
2407 // Close all windows via the menu item. 2407 // Close all windows via the menu item.
2408 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE); 2408 CloseBrowserWindow(browser(), menu1.get(), LauncherContextMenu::MENU_CLOSE);
2409 EXPECT_EQ(0u, BrowserList::GetInstance()->size()); 2409 EXPECT_EQ(0u, BrowserList::GetInstance()->size());
2410 2410
2411 // Check if "Close" is removed from the context menu. 2411 // Check if "Close" is removed from the context menu.
2412 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu(); 2412 std::unique_ptr<LauncherContextMenu> menu2 = CreateBrowserItemContextMenu();
2413 ASSERT_FALSE( 2413 ASSERT_FALSE(
2414 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE)); 2414 IsItemPresentInMenu(menu2.get(), LauncherContextMenu::MENU_CLOSE));
2415 } 2415 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698