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

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

Issue 2773493002: [Merge M58] arc: Fix regression in handling ARC shelf item. (Closed)
Patch Set: resolve merge conflicts and adopt to M58 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 5206b7b8c18e697bf41a87c910f3aa75edf5ccb3..57574c368c98b82b8f0ef383fe80c2ec0adb07ef 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
@@ -110,6 +110,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"
@@ -328,6 +329,12 @@ class ProxyShelfDelegate : public ash::ShelfDelegate {
DISALLOW_COPY_AND_ASSIGN(ProxyShelfDelegate);
};
+// Simulates selection of the shelf item.
+void SelectItem(LauncherItemController* delegate) {
+ delegate->ItemSelected(ui::ET_MOUSE_PRESSED, ui::EF_NONE,
+ display::kInvalidDisplayId, ash::LAUNCH_FROM_UNKNOWN);
+}
+
} // namespace
class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
@@ -3739,6 +3746,65 @@ TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
"AppList, Chrome");
}
+// Test the application menu of a shelf item with multiple ARC windows.
+TEST_F(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.
+ ash::ShelfAppMenuItemList 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