Commit 78ca7f9d authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: makes ServerWindow install pre-target handler using kDefault

Using kSystem means it conflicts with other system level landers, such as
the laser pointer.

BUG=867483
TEST=covered by tests

Change-Id: I40581e6ae8716e333d1e64ecd2ae8ebbcbf1936d
Reviewed-on: https://chromium-review.googlesource.com/1151546Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578438}
parent 0c006dc4
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "ash/public/cpp/config.h" #include "ash/public/cpp/config.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "services/ui/ws2/server_window.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
namespace ash { namespace ash {
...@@ -154,4 +155,25 @@ TEST_F(LaserPointerControllerTest, LaserPointerPrediction) { ...@@ -154,4 +155,25 @@ TEST_F(LaserPointerControllerTest, LaserPointerPrediction) {
controller_test_api_->predicted_laser_points().GetNumberOfPoints()); controller_test_api_->predicted_laser_points().GetNumberOfPoints());
} }
// Test to laser pointer is shown for touches over a remote app.
TEST_F(LaserPointerControllerTest, LaserPointerWorksWithRemoteApp) {
std::unique_ptr<aura::Window> window =
CreateTestWindow(gfx::Rect(50, 50, 100, 100));
ui::ws2::ServerWindow* server_window =
ui::ws2::ServerWindow::GetMayBeNull(window.get());
ASSERT_TRUE(server_window);
// Setting the client area triggers slightly different logic.
server_window->SetClientArea(gfx::Insets(10), std::vector<gfx::Rect>());
// The laser pointer mode only works with stylus.
ui::test::EventGenerator* event_generator = GetEventGenerator();
event_generator->EnterPenPointerMode();
controller_test_api_->SetEnabled(true);
event_generator->MoveTouch(gfx::Point(100, 100));
EXPECT_FALSE(controller_test_api_->IsShowingLaserPointer());
event_generator->PressTouch();
EXPECT_TRUE(controller_test_api_->IsShowingLaserPointer());
}
} // namespace ash } // namespace ash
...@@ -104,8 +104,8 @@ class AshTestBase : public testing::Test { ...@@ -104,8 +104,8 @@ class AshTestBase : public testing::Test {
// |bounds_in_screen|. |shell_window_id| is the shell window id to give to // |bounds_in_screen|. |shell_window_id| is the shell window id to give to
// the new window. // the new window.
// //
// In classic mode this simulates creating a window as a client of Ash would. // This function simulates creating a window as a client of Ash would. That
// That is, it goes through the WindowService. // is, it goes through the WindowService.
// //
// TODO(sky): convert existing CreateTestWindow() functions into this one. // TODO(sky): convert existing CreateTestWindow() functions into this one.
std::unique_ptr<aura::Window> CreateTestWindow( std::unique_ptr<aura::Window> CreateTestWindow(
......
...@@ -13,6 +13,9 @@ component("lib") { ...@@ -13,6 +13,9 @@ component("lib") {
friend = [ friend = [
":tests", ":tests",
":test_support", ":test_support",
# It's ok for tests to depend upon private code.
"//ash:ash_unittests",
] ]
public = [ public = [
"gpu_interface_provider.h", "gpu_interface_provider.h",
......
...@@ -126,7 +126,9 @@ class ServerWindowEventHandler : public ui::EventHandler { ...@@ -126,7 +126,9 @@ class ServerWindowEventHandler : public ui::EventHandler {
public: public:
explicit ServerWindowEventHandler(ServerWindow* server_window) explicit ServerWindowEventHandler(ServerWindow* server_window)
: server_window_(server_window) { : server_window_(server_window) {
window()->AddPreTargetHandler(this, ui::EventTarget::Priority::kSystem); // Use |kDefault| so as not to conflict with other important pre-target
// handlers (such as laser pointer).
window()->AddPreTargetHandler(this, ui::EventTarget::Priority::kDefault);
} }
~ServerWindowEventHandler() override { ~ServerWindowEventHandler() override {
window()->RemovePreTargetHandler(this); window()->RemovePreTargetHandler(this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment