Skip to content

Commit

Permalink
chromeos: makes ServerWindow install pre-target handler using kDefault
Browse files Browse the repository at this point in the history
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/1151546
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578438}
  • Loading branch information
Scott Violet authored and Commit Bot committed Jul 26, 2018
1 parent 0c006dc commit 78ca7f9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
22 changes: 22 additions & 0 deletions ash/laser/laser_pointer_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ash/public/cpp/config.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "services/ui/ws2/server_window.h"
#include "ui/events/test/event_generator.h"

namespace ash {
Expand Down Expand Up @@ -154,4 +155,25 @@ TEST_F(LaserPointerControllerTest, LaserPointerPrediction) {
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
4 changes: 2 additions & 2 deletions ash/test/ash_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class AshTestBase : public testing::Test {
// |bounds_in_screen|. |shell_window_id| is the shell window id to give to
// the new window.
//
// In classic mode this simulates creating a window as a client of Ash would.
// That is, it goes through the WindowService.
// This function simulates creating a window as a client of Ash would. That
// is, it goes through the WindowService.
//
// TODO(sky): convert existing CreateTestWindow() functions into this one.
std::unique_ptr<aura::Window> CreateTestWindow(
Expand Down
3 changes: 3 additions & 0 deletions services/ui/ws2/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ component("lib") {
friend = [
":tests",
":test_support",

# It's ok for tests to depend upon private code.
"//ash:ash_unittests",
]
public = [
"gpu_interface_provider.h",
Expand Down
4 changes: 3 additions & 1 deletion services/ui/ws2/server_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ class ServerWindowEventHandler : public ui::EventHandler {
public:
explicit ServerWindowEventHandler(ServerWindow* 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 {
window()->RemovePreTargetHandler(this);
Expand Down

0 comments on commit 78ca7f9

Please sign in to comment.