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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc

Issue 2763893004: arc: Fix regression in handling ARC shelf item. (Closed)
Patch Set: comments updated 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc ('k') | no next file » | 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_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..a59b65072af62c083a0421a5cdc7a8bd2a79b901 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,65 @@ TEST_P(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
"AppList, Chrome");
}
+// Test the application menu of a shelf item with multiple ARC windows.
+TEST_P(ChromeLauncherControllerImplWithArcTest, ShelfItemWithMultipleWindows) {
+ 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_id =
+ launcher_controller_->GetShelfIDForAppID(app_id);
+ LauncherItemController* item_controller =
+ launcher_controller_->GetLauncherItemController(shelf_id);
+ ASSERT_TRUE(item_controller);
+
+ // Selecting the item will show its application menu. It does not change the
+ // active window.
+ SelectItem(item_controller);
+ EXPECT_FALSE(window1->IsActive());
+ EXPECT_TRUE(window2->IsActive());
+
+ // Command ids are just app window indices. Note, apps are registered in
+ // 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 will show its application menu. It does not change the
+ // 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
« no previous file with comments | « chrome/browser/ui/ash/launcher/arc_app_window_launcher_item_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698