| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/host/ash_window_tree_host_x11.h" | 5 #include "ash/host/ash_window_tree_host_x11.h" |
| 6 | 6 |
| 7 #undef None | 7 #undef None |
| 8 #undef Bool | 8 #undef Bool |
| 9 | 9 |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 int last_touch_id_; | 49 int last_touch_id_; |
| 50 gfx::Point last_touch_location_; | 50 gfx::Point last_touch_location_; |
| 51 | 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(RootWindowEventHandler); | 52 DISALLOW_COPY_AND_ASSIGN(RootWindowEventHandler); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 namespace ash { | 57 namespace ash { |
| 58 | 58 |
| 59 typedef aura::test::AuraTestBase WindowTreeHostX11Test; | 59 class WindowTreeHostX11Test : public aura::test::AuraTestBase { |
| 60 public: |
| 61 virtual void SetUp() OVERRIDE { |
| 62 aura::test::AuraTestBase::SetUp(); |
| 63 |
| 64 #if defined(OS_CHROMEOS) |
| 65 // Fake a ChromeOS running env. |
| 66 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; |
| 67 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
| 68 #endif |
| 69 } |
| 70 |
| 71 virtual void TearDown() OVERRIDE { |
| 72 aura::test::AuraTestBase::TearDown(); |
| 73 |
| 74 #if defined(OS_CHROMEOS) |
| 75 // Revert the CrOS testing env otherwise the following non-CrOS aura |
| 76 // tests will fail. |
| 77 // Fake a ChromeOS running env. |
| 78 const char* kLsbRelease = ""; |
| 79 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
| 80 #endif |
| 81 } |
| 82 }; |
| 60 | 83 |
| 61 // Send X touch events to one WindowTreeHost. The WindowTreeHost's | 84 // Send X touch events to one WindowTreeHost. The WindowTreeHost's |
| 62 // delegate will get corresponding ui::TouchEvent if the touch events | 85 // delegate will get corresponding ui::TouchEvent if the touch events |
| 63 // are winthin the bound of the WindowTreeHost. | 86 // are winthin the bound of the WindowTreeHost. |
| 64 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { | 87 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) { |
| 65 // Fake a ChromeOS running env. | |
| 66 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | |
| 67 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | |
| 68 | |
| 69 scoped_ptr<AshWindowTreeHostX11> window_tree_host( | 88 scoped_ptr<AshWindowTreeHostX11> window_tree_host( |
| 70 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); | 89 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); |
| 71 window_tree_host->InitHost(); | 90 window_tree_host->InitHost(); |
| 72 scoped_ptr<RootWindowEventHandler> handler( | 91 scoped_ptr<RootWindowEventHandler> handler( |
| 73 new RootWindowEventHandler(window_tree_host.get())); | 92 new RootWindowEventHandler(window_tree_host.get())); |
| 74 | 93 |
| 75 std::vector<unsigned int> devices; | 94 std::vector<unsigned int> devices; |
| 76 devices.push_back(0); | 95 devices.push_back(0); |
| 77 ui::SetUpTouchDevicesForTest(devices); | 96 ui::SetUpTouchDevicesForTest(devices); |
| 78 std::vector<ui::Valuator> valuators; | 97 std::vector<ui::Valuator> valuators; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 105 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); | 124 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); |
| 106 | 125 |
| 107 scoped_xevent.InitTouchEvent( | 126 scoped_xevent.InitTouchEvent( |
| 108 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); | 127 0, XI_TouchEnd, 5, gfx::Point(1500, 1600), valuators); |
| 109 window_tree_host->DispatchEvent(scoped_xevent); | 128 window_tree_host->DispatchEvent(scoped_xevent); |
| 110 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); | 129 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler->last_touch_type()); |
| 111 EXPECT_EQ(0, handler->last_touch_id()); | 130 EXPECT_EQ(0, handler->last_touch_id()); |
| 112 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); | 131 EXPECT_EQ(gfx::Point(1500, 1600), handler->last_touch_location()); |
| 113 | 132 |
| 114 handler.reset(); | 133 handler.reset(); |
| 115 | |
| 116 // Revert the CrOS testing env otherwise the following non-CrOS aura | |
| 117 // tests will fail. | |
| 118 // Fake a ChromeOS running env. | |
| 119 kLsbRelease = ""; | |
| 120 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | |
| 121 } | 134 } |
| 122 | 135 |
| 123 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is | 136 // Send X touch events to two WindowTreeHost. The WindowTreeHost which is |
| 124 // the event target of the X touch events should generate the corresponding | 137 // the event target of the X touch events should generate the corresponding |
| 125 // ui::TouchEvent for its delegate. | 138 // ui::TouchEvent for its delegate. |
| 126 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { | 139 TEST_F(WindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) { |
| 127 // Fake a ChromeOS running env. | |
| 128 const char* kLsbRelease = "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | |
| 129 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | |
| 130 | |
| 131 scoped_ptr<AshWindowTreeHostX11> window_tree_host1( | 140 scoped_ptr<AshWindowTreeHostX11> window_tree_host1( |
| 132 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); | 141 new AshWindowTreeHostX11(gfx::Rect(0, 0, 2560, 1700))); |
| 133 window_tree_host1->InitHost(); | 142 window_tree_host1->InitHost(); |
| 134 scoped_ptr<RootWindowEventHandler> handler1( | 143 scoped_ptr<RootWindowEventHandler> handler1( |
| 135 new RootWindowEventHandler(window_tree_host1.get())); | 144 new RootWindowEventHandler(window_tree_host1.get())); |
| 136 | 145 |
| 137 int host2_y_offset = 1700; | 146 int host2_y_offset = 1700; |
| 138 scoped_ptr<AshWindowTreeHostX11> window_tree_host2( | 147 scoped_ptr<AshWindowTreeHostX11> window_tree_host2( |
| 139 new AshWindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); | 148 new AshWindowTreeHostX11(gfx::Rect(0, host2_y_offset, 1920, 1080))); |
| 140 window_tree_host2->InitHost(); | 149 window_tree_host2->InitHost(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); | 228 EXPECT_EQ(ui::ET_UNKNOWN, handler1->last_touch_type()); |
| 220 EXPECT_EQ(-1, handler1->last_touch_id()); | 229 EXPECT_EQ(-1, handler1->last_touch_id()); |
| 221 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); | 230 EXPECT_EQ(gfx::Point(0, 0), handler1->last_touch_location()); |
| 222 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); | 231 EXPECT_EQ(ui::ET_TOUCH_RELEASED, handler2->last_touch_type()); |
| 223 EXPECT_EQ(1, handler2->last_touch_id()); | 232 EXPECT_EQ(1, handler2->last_touch_id()); |
| 224 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), | 233 EXPECT_EQ(gfx::Point(1600, 2650 - host2_y_offset), |
| 225 handler2->last_touch_location()); | 234 handler2->last_touch_location()); |
| 226 | 235 |
| 227 handler1.reset(); | 236 handler1.reset(); |
| 228 handler2.reset(); | 237 handler2.reset(); |
| 229 | |
| 230 // Revert the CrOS testing env otherwise the following non-CrOS aura | |
| 231 // tests will fail. | |
| 232 // Fake a ChromeOS running env. | |
| 233 kLsbRelease = ""; | |
| 234 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | |
| 235 } | 238 } |
| 236 | 239 |
| 237 } // namespace aura | 240 } // namespace aura |
| OLD | NEW |