| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 5 |
| 6 #include "base/sys_info.h" | 6 #include "base/sys_info.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
| 9 #include "ui/aura/window_event_dispatcher.h" | 9 #include "ui/aura/window_event_dispatcher.h" |
| 10 #include "ui/aura/window_tree_host_delegate.h" | 10 #include "ui/aura/window_tree_host_delegate.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 std::vector<unsigned int> devices; | 112 std::vector<unsigned int> devices; |
| 113 devices.push_back(0); | 113 devices.push_back(0); |
| 114 ui::SetUpTouchDevicesForTest(devices); | 114 ui::SetUpTouchDevicesForTest(devices); |
| 115 std::vector<ui::Valuator> valuators; | 115 std::vector<ui::Valuator> valuators; |
| 116 | 116 |
| 117 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); | 117 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); |
| 118 EXPECT_EQ(-1, delegate->last_touch_id()); | 118 EXPECT_EQ(-1, delegate->last_touch_id()); |
| 119 | 119 |
| 120 ui::ScopedXI2Event scoped_xevent; | 120 ui::ScopedXI2Event scoped_xevent; |
| 121 #if defined(OS_CHROMEOS) | 121 #if defined(OS_CHROMEOS) |
| 122 // This touch is out of bounds. | 122 // This touch device does not have TouchCTM stored in the root window. |
| 123 // So touch event is discarded. |
| 123 scoped_xevent.InitTouchEvent( | 124 scoped_xevent.InitTouchEvent( |
| 124 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); | 125 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); |
| 125 window_tree_host->Dispatch(scoped_xevent); | 126 window_tree_host->Dispatch(scoped_xevent); |
| 126 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); | 127 EXPECT_EQ(ui::ET_UNKNOWN, delegate->last_touch_type()); |
| 127 EXPECT_EQ(-1, delegate->last_touch_id()); | 128 EXPECT_EQ(-1, delegate->last_touch_id()); |
| 128 EXPECT_EQ(gfx::Point(0, 0), delegate->last_touch_location()); | 129 EXPECT_EQ(gfx::Point(0, 0), delegate->last_touch_location()); |
| 129 #endif // defined(OS_CHROMEOS) | 130 #endif // defined(OS_CHROMEOS) |
| 130 | 131 |
| 132 // Make the touchscreen 0 associated with the root window. |
| 133 window_tree_host->SetTouchCTM(0, TouchCTM()); |
| 134 |
| 131 // Following touchs are within bounds and are passed to delegate. | 135 // Following touchs are within bounds and are passed to delegate. |
| 132 scoped_xevent.InitTouchEvent( | 136 scoped_xevent.InitTouchEvent( |
| 133 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators); | 137 0, XI_TouchBegin, 5, gfx::Point(1500, 1500), valuators); |
| 134 window_tree_host->Dispatch(scoped_xevent); | 138 window_tree_host->Dispatch(scoped_xevent); |
| 135 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate->last_touch_type()); | 139 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate->last_touch_type()); |
| 136 EXPECT_EQ(0, delegate->last_touch_id()); | 140 EXPECT_EQ(0, delegate->last_touch_id()); |
| 137 EXPECT_EQ(gfx::Point(1500, 1500), delegate->last_touch_location()); | 141 EXPECT_EQ(gfx::Point(1500, 1500), delegate->last_touch_location()); |
| 138 | 142 |
| 139 scoped_xevent.InitTouchEvent( | 143 scoped_xevent.InitTouchEvent( |
| 140 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators); | 144 0, XI_TouchUpdate, 5, gfx::Point(1500, 1600), valuators); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 std::vector<unsigned int> devices; | 188 std::vector<unsigned int> devices; |
| 185 devices.push_back(0); | 189 devices.push_back(0); |
| 186 ui::SetUpTouchDevicesForTest(devices); | 190 ui::SetUpTouchDevicesForTest(devices); |
| 187 std::vector<ui::Valuator> valuators; | 191 std::vector<ui::Valuator> valuators; |
| 188 | 192 |
| 189 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 193 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); |
| 190 EXPECT_EQ(-1, delegate1->last_touch_id()); | 194 EXPECT_EQ(-1, delegate1->last_touch_id()); |
| 191 EXPECT_EQ(ui::ET_UNKNOWN, delegate2->last_touch_type()); | 195 EXPECT_EQ(ui::ET_UNKNOWN, delegate2->last_touch_type()); |
| 192 EXPECT_EQ(-1, delegate2->last_touch_id()); | 196 EXPECT_EQ(-1, delegate2->last_touch_id()); |
| 193 | 197 |
| 198 // Make the touchscreen 0 associated with the second root window. |
| 199 window_tree_host2->SetTouchCTM(0, TouchCTM()); |
| 200 |
| 194 // 2 Touch events are targeted at the second WindowTreeHost. | 201 // 2 Touch events are targeted at the second WindowTreeHost. |
| 195 ui::ScopedXI2Event scoped_xevent; | 202 ui::ScopedXI2Event scoped_xevent; |
| 196 scoped_xevent.InitTouchEvent( | 203 scoped_xevent.InitTouchEvent( |
| 197 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); | 204 0, XI_TouchBegin, 5, gfx::Point(1500, 2500), valuators); |
| 198 window_tree_host1->Dispatch(scoped_xevent); | 205 window_tree_host1->Dispatch(scoped_xevent); |
| 199 window_tree_host2->Dispatch(scoped_xevent); | 206 window_tree_host2->Dispatch(scoped_xevent); |
| 200 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); | 207 EXPECT_EQ(ui::ET_UNKNOWN, delegate1->last_touch_type()); |
| 201 EXPECT_EQ(-1, delegate1->last_touch_id()); | 208 EXPECT_EQ(-1, delegate1->last_touch_id()); |
| 202 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); | 209 EXPECT_EQ(gfx::Point(0, 0), delegate1->last_touch_location()); |
| 203 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type()); | 210 EXPECT_EQ(ui::ET_TOUCH_PRESSED, delegate2->last_touch_type()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 274 |
| 268 // Revert the CrOS testing env otherwise the following non-CrOS aura | 275 // Revert the CrOS testing env otherwise the following non-CrOS aura |
| 269 // tests will fail. | 276 // tests will fail. |
| 270 // Fake a ChromeOS running env. | 277 // Fake a ChromeOS running env. |
| 271 kLsbRelease = ""; | 278 kLsbRelease = ""; |
| 272 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | 279 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
| 273 } | 280 } |
| 274 #endif // defined(OS_CHROMEOS) | 281 #endif // defined(OS_CHROMEOS) |
| 275 | 282 |
| 276 } // namespace aura | 283 } // namespace aura |
| OLD | NEW |