| Index: ash/host/ash_window_tree_host_x11_unittest.cc
|
| diff --git a/ash/host/ash_window_tree_host_x11_unittest.cc b/ash/host/ash_window_tree_host_x11_unittest.cc
|
| index efd25c04e26e5fb849f5fd2e9f288aa7460f12e5..d2c7b11cc683aeee7c96f5c2ecbc6c6140b1eae4 100644
|
| --- a/ash/host/ash_window_tree_host_x11_unittest.cc
|
| +++ b/ash/host/ash_window_tree_host_x11_unittest.cc
|
| @@ -12,6 +12,7 @@
|
| #include "ui/aura/test/aura_test_base.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/aura/window_event_dispatcher.h"
|
| +#include "ui/aura/window_tree_host_x11.h"
|
| #include "ui/events/event_processor.h"
|
| #include "ui/events/event_target.h"
|
| #include "ui/events/event_target_iterator.h"
|
| @@ -56,19 +57,20 @@ class RootWindowEventHandler : public ui::EventHandler {
|
|
|
| namespace ash {
|
|
|
| -typedef aura::test::AuraTestBase WindowTreeHostX11Test;
|
| +typedef aura::test::AuraTestBase AshWindowTreeHostX11Test;
|
|
|
| // Send X touch events to one WindowTreeHost. The WindowTreeHost's
|
| // delegate will get corresponding ui::TouchEvent if the touch events
|
| -// are winthin the bound of the WindowTreeHost.
|
| -TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
|
| +// are targeting this WindowTreeHost.
|
| +TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
|
| // Fake a ChromeOS running env.
|
| const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
|
| base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
|
|
|
| - scoped_ptr<AshWindowTreeHostX11> window_tree_host(
|
| + scoped_ptr<aura::WindowTreeHostX11> window_tree_host(
|
| new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700)));
|
| window_tree_host->InitHost();
|
| + ::Window target = DefaultRootWindow(gfx::GetXDisplay());
|
| scoped_ptr<RootWindowEventHandler> handler(
|
| new RootWindowEventHandler(window_tree_host.get()));
|
|
|
| @@ -83,30 +85,34 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
|
| ui::ScopedXI2Event scoped_xevent;
|
| // This touch is out of bounds.
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators);
|
| - window_tree_host->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators, target);
|
| + if (window_tree_host->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_UNKNOWN, handler->last_touch_type());
|
| EXPECT_EQ(-1, handler->last_touch_id());
|
| EXPECT_EQ(gfx::Point(0, 0), handler->last_touch_location());
|
|
|
| // Following touchs are within bounds and are passed to delegate.
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators);
|
| - window_tree_host->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators, target);
|
| + if (window_tree_host->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler->last_touch_type());
|
| EXPECT_EQ(0, handler->last_touch_id());
|
| EXPECT_EQ(gfx::Point(1500, 1500), handler->last_touch_location());
|
|
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators);
|
| - window_tree_host->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators, target);
|
| + if (window_tree_host->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_TOUCH_MOVED, handler->last_touch_type());
|
| EXPECT_EQ(0, handler->last_touch_id());
|
| EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location());
|
|
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators);
|
| - window_tree_host->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators, target);
|
| + if (window_tree_host->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type());
|
| EXPECT_EQ(0, handler->last_touch_id());
|
| EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location());
|
| @@ -123,24 +129,26 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
|
| // Send X touch events to two WindowTreeHost. The WindowTreeHost which is
|
| // the event target of the X touch events should generate the corresponding
|
| // ui::TouchEvent for its delegate.
|
| -TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) {
|
| +TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) {
|
| // Fake a ChromeOS running env.
|
| const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n";
|
| base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
|
|
|
| - scoped_ptr<AshWindowTreeHostX11> window_tree_host1(
|
| + scoped_ptr<aura::WindowTreeHostX11> window_tree_host1(
|
| new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700)));
|
| window_tree_host1->InitHost();
|
| scoped_ptr<RootWindowEventHandler> handler1(
|
| new RootWindowEventHandler(window_tree_host1.get()));
|
|
|
| int host2_y_offset = 1700;
|
| - scoped_ptr<AshWindowTreeHostX11> window_tree_host2(
|
| + scoped_ptr<aura::WindowTreeHostX11> window_tree_host2(
|
| new AshWindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080)));
|
| window_tree_host2->InitHost();
|
| scoped_ptr<RootWindowEventHandler> handler2(
|
| new RootWindowEventHandler(window_tree_host2.get()));
|
|
|
| + ::Window target = DefaultRootWindow(gfx::GetXDisplay());
|
| +
|
| std::vector<unsigned int> devices;
|
| devices.push_back(0);
|
| ui::SetUpTouchDevicesForTest(devices);
|
| @@ -154,75 +162,82 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) {
|
| // 2 Touch events are targeted at the second WindowTreeHost.
|
| ui::ScopedXI2Event scoped_xevent;
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators);
|
| - window_tree_host1->DispatchEvent(scoped_xevent);
|
| - window_tree_host2->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators, target);
|
| + if (window_tree_host1->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host1->DispatchEvent(scoped_xevent);
|
| + if (window_tree_host2->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host2->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
|
| EXPECT_EQ(-1, handler1->last_touch_id());
|
| EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
|
| EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type());
|
| EXPECT_EQ(0, handler2->last_touch_id());
|
| - EXPECT_EQ(gfx::Point(1500, 2500 - host2_y_offset),
|
| - handler2->last_touch_location());
|
| + EXPECT_EQ(gfx::Point(1500, 2500), handler2->last_touch_location());
|
|
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators);
|
| - window_tree_host1->DispatchEvent(scoped_xevent);
|
| - window_tree_host2->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchBegin, 6, gfx::Point(1600, 2600), valuators, target);
|
| + if (window_tree_host1->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host1->DispatchEvent(scoped_xevent);
|
| + if (window_tree_host2->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host2->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
|
| EXPECT_EQ(-1, handler1->last_touch_id());
|
| EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
|
| EXPECT_EQ(ui::ET_TOUCH_PRESSED, handler2->last_touch_type());
|
| EXPECT_EQ(1, handler2->last_touch_id());
|
| - EXPECT_EQ(gfx::Point(1600, 2600 - host2_y_offset),
|
| - handler2->last_touch_location());
|
| + EXPECT_EQ(gfx::Point(1600, 2600), handler2->last_touch_location());
|
|
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators);
|
| - window_tree_host1->DispatchEvent(scoped_xevent);
|
| - window_tree_host2->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchUpdate, 5, gfx::Point(1500, 2550), valuators, target);
|
| + if (window_tree_host1->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host1->DispatchEvent(scoped_xevent);
|
| + if (window_tree_host2->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host2->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
|
| EXPECT_EQ(-1, handler1->last_touch_id());
|
| EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
|
| EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type());
|
| EXPECT_EQ(0, handler2->last_touch_id());
|
| - EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset),
|
| - handler2->last_touch_location());
|
| + EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location());
|
|
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators);
|
| - window_tree_host1->DispatchEvent(scoped_xevent);
|
| - window_tree_host2->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchUpdate, 6, gfx::Point(1600, 2650), valuators, target);
|
| + if (window_tree_host1->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host1->DispatchEvent(scoped_xevent);
|
| + if (window_tree_host2->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host2->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
|
| EXPECT_EQ(-1, handler1->last_touch_id());
|
| EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
|
| EXPECT_EQ(ui::ET_TOUCH_MOVED, handler2->last_touch_type());
|
| EXPECT_EQ(1, handler2->last_touch_id());
|
| - EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset),
|
| - handler2->last_touch_location());
|
| + EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location());
|
|
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators);
|
| - window_tree_host1->DispatchEvent(scoped_xevent);
|
| - window_tree_host2->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchEnd, 5, gfx::Point(1500, 2550), valuators, target);
|
| + if (window_tree_host1->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host1->DispatchEvent(scoped_xevent);
|
| + if (window_tree_host2->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host2->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
|
| EXPECT_EQ(-1, handler1->last_touch_id());
|
| EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
|
| EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type());
|
| EXPECT_EQ(0, handler2->last_touch_id());
|
| - EXPECT_EQ(gfx::Point(1500, 2550 - host2_y_offset),
|
| - handler2->last_touch_location());
|
| + EXPECT_EQ(gfx::Point(1500, 2550), handler2->last_touch_location());
|
| +
|
| scoped_xevent.InitTouchEvent(
|
| - 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators);
|
| - window_tree_host1->DispatchEvent(scoped_xevent);
|
| - window_tree_host2->DispatchEvent(scoped_xevent);
|
| + 0, XI_TouchEnd, 6, gfx::Point(1600, 2650), valuators, target);
|
| + if (window_tree_host1->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host1->DispatchEvent(scoped_xevent);
|
| + if (window_tree_host2->CanDispatchEvent(scoped_xevent))
|
| + window_tree_host2->DispatchEvent(scoped_xevent);
|
| EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type());
|
| EXPECT_EQ(-1, handler1->last_touch_id());
|
| EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location());
|
| EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type());
|
| EXPECT_EQ(1, handler2->last_touch_id());
|
| - EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset),
|
| - handler2->last_touch_location());
|
| + EXPECT_EQ(gfx::Point(1600, 2650), handler2->last_touch_location());
|
|
|
| handler1.reset();
|
| handler2.reset();
|
|
|