Chromium Code Reviews| Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc |
| diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc |
| index 6d485f5d00597645f0d8d7b0f0ac2e5eb21bd1d7..993b436e196d5a7bb1da48acec732522b5358fd9 100644 |
| --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc |
| +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc |
| @@ -111,6 +111,7 @@ |
| #include "ui/display/display.h" |
| #include "ui/display/display_switches.h" |
| #include "ui/display/screen.h" |
| +#include "ui/events/base_event_utils.h" |
| #include "ui/events/event_constants.h" |
| #include "ui/views/widget/widget.h" |
| @@ -322,6 +323,18 @@ class ProxyShelfDelegate : public ash::ShelfDelegate { |
| DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate); |
| }; |
| +// A callback that does nothing after shelf item selection handling. |
| +void NoopCallback(ash::ShelfAction action, base::Optional<MenuItemList>) {} |
| + |
| +// Simulates selection of the shelf item. |
| +void SelectItem(ash::mojom::ShelfItemDelegate* delegate) { |
| + std::unique_ptr<ui::Event> event = base::MakeUnique<ui::MouseEvent>( |
| + ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), ui::EventTimeForNow(), |
| + ui::EF_NONE, 0); |
| + delegate->ItemSelected(std::move(event), display::kInvalidDisplayId, |
| + ash::LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback)); |
| +} |
| + |
| } // namespace |
| class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest { |
| @@ -3773,6 +3786,64 @@ TEST_P(ChromeLauncherControllerImplWithArcTest, ArcManaged) { |
| "AppList, Chrome"); |
| } |
| +// Test that validates correctness of switching multiple shelf item for the same |
|
msw
2017/03/22 00:30:15
nit: maybe "Test the application menu of a shelf i
khmel
2017/03/22 00:39:57
Done.
|
| +// ARC app. |
| +TEST_P(ChromeLauncherControllerImplWithArcTest, MultipleItemsInShelf) { |
|
msw
2017/03/22 00:30:15
nit: maybe s/MultipleItemsInShelf/ShelfItemWithMul
khmel
2017/03/22 00:39:57
Done.
|
| + InitLauncherControllerWithBrowser(); |
| + |
| + arc::mojom::AppInfo appinfo = |
| + CreateAppInfo("Test1", "test", "com.example.app", OrientationLock::NONE); |
| + AddArcAppAndShortcut(appinfo); |
| + |
| + // Widgets will be deleted by the system. |
| + NotifyOnTaskCreated(appinfo, 1 /* task_id */); |
| + views::Widget* window1 = CreateArcWindow("org.chromium.arc.1"); |
| + ASSERT_TRUE(window1); |
| + EXPECT_TRUE(window1->IsActive()); |
| + |
| + NotifyOnTaskCreated(appinfo, 2 /* task_id */); |
| + views::Widget* window2 = CreateArcWindow("org.chromium.arc.2"); |
| + ASSERT_TRUE(window2); |
| + |
| + EXPECT_FALSE(window1->IsActive()); |
| + EXPECT_TRUE(window2->IsActive()); |
| + |
| + const std::string app_id = ArcAppTest::GetAppId(appinfo); |
| + |
| + const ash::ShelfID shelf_app_id = |
|
msw
2017/03/22 00:30:15
nit: name this |shelf_id|, it's not an app_id stri
khmel
2017/03/22 00:39:58
Done.
|
| + launcher_controller_->GetShelfIDForAppID(app_id); |
| + LauncherItemController* item_controller = |
| + launcher_controller_->GetLauncherItemController(shelf_app_id); |
| + ASSERT_TRUE(item_controller); |
| + |
| + // Selecting the item does not change active window. |
|
msw
2017/03/22 00:30:15
nit: maybe "Selecting the item will show its appli
khmel
2017/03/22 00:39:57
Done.
|
| + SelectItem(item_controller); |
| + EXPECT_FALSE(window1->IsActive()); |
| + EXPECT_TRUE(window2->IsActive()); |
| + |
| + // Command ids is just app window indices. Note, apps is registered in |
|
msw
2017/03/22 00:30:15
nit: s/is/are/ in both cases
khmel
2017/03/22 00:39:57
Done.
|
| + // opposite order. Last created goes in front. |
| + MenuItemList items = item_controller->GetAppMenuItems(0); |
| + ASSERT_EQ(items.size(), 2U); |
| + EXPECT_EQ(items[0]->command_id, 0U); |
| + EXPECT_EQ(items[1]->command_id, 1U); |
| + |
| + // Execute command to activate first window. |
| + item_controller->ExecuteCommand(items[1]->command_id, 0); |
| + EXPECT_TRUE(window1->IsActive()); |
| + EXPECT_FALSE(window2->IsActive()); |
| + |
| + // Selecting the item does not change active window. |
| + SelectItem(item_controller); |
| + EXPECT_TRUE(window1->IsActive()); |
| + EXPECT_FALSE(window2->IsActive()); |
| + |
| + // Execute command to activate second window. |
| + item_controller->ExecuteCommand(items[0]->command_id, 0); |
| + EXPECT_FALSE(window1->IsActive()); |
| + EXPECT_TRUE(window2->IsActive()); |
| +} |
| + |
| namespace { |
| class ChromeLauncherControllerOrientationTest |