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..12aa7bb51807628ebf134160bbc1048358dec47f 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,17 +57,17 @@ 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(); |
scoped_ptr<RootWindowEventHandler> handler( |
@@ -84,7 +85,8 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { |
// This touch is out of bounds. |
scoped_xevent.InitTouchEvent( |
0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); |
- window_tree_host->DispatchEvent(scoped_xevent); |
+ 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()); |
@@ -92,21 +94,24 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { |
// 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); |
+ 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); |
+ 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); |
+ 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,19 +128,19 @@ 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( |
@@ -155,74 +160,81 @@ TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { |
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); |
+ 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); |
+ 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); |
+ 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); |
+ 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); |
+ 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); |
+ 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(); |