| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/aura/root_window.h" | 5 #include "ui/aura/root_window.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/aura/client/event_client.h" | 10 #include "ui/aura/client/event_client.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 EXPECT_EQ("100,100", root.location().ToString()); | 202 EXPECT_EQ("100,100", root.location().ToString()); |
| 203 EXPECT_EQ("100,100", root.root_location().ToString()); | 203 EXPECT_EQ("100,100", root.root_location().ToString()); |
| 204 | 204 |
| 205 ui::MouseEvent translated_event( | 205 ui::MouseEvent translated_event( |
| 206 root, static_cast<Window*>(root_window()), w1.get(), | 206 root, static_cast<Window*>(root_window()), w1.get(), |
| 207 ui::ET_MOUSE_ENTERED, root.flags()); | 207 ui::ET_MOUSE_ENTERED, root.flags()); |
| 208 EXPECT_EQ("50,50", translated_event.location().ToString()); | 208 EXPECT_EQ("50,50", translated_event.location().ToString()); |
| 209 EXPECT_EQ("100,100", translated_event.root_location().ToString()); | 209 EXPECT_EQ("100,100", translated_event.root_location().ToString()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 #if defined(OS_CHROMEOS) | |
| 213 // Make sure the mouse location is translated within the root | |
| 214 // window. crbug.com/222483. | |
| 215 TEST_F(RootWindowTest, KeepTranslatedEventInRoot) { | |
| 216 // Clockwise. | |
| 217 gfx::Transform rotate; | |
| 218 rotate.Translate(599, 0); | |
| 219 rotate.Rotate(90); | |
| 220 root_window()->SetTransform(rotate); | |
| 221 | |
| 222 gfx::Point top_edge_on_host(100, 0); | |
| 223 ui::MouseEvent top_event(ui::ET_MOUSE_PRESSED, | |
| 224 top_edge_on_host, | |
| 225 top_edge_on_host, 0); | |
| 226 root_window()->TransformEventForDeviceScaleFactor(true, &top_event); | |
| 227 EXPECT_TRUE(root_window()->bounds().Contains(top_event.location())); | |
| 228 | |
| 229 // Counter clockwise. | |
| 230 rotate.MakeIdentity(); | |
| 231 rotate.Translate(0, 799); | |
| 232 rotate.Rotate(270); | |
| 233 root_window()->SetTransform(rotate); | |
| 234 | |
| 235 gfx::Point bottom_edge_on_host(500, 799); | |
| 236 ui::MouseEvent bottom_event(ui::ET_MOUSE_PRESSED, | |
| 237 bottom_edge_on_host, | |
| 238 bottom_edge_on_host, 0); | |
| 239 root_window()->TransformEventForDeviceScaleFactor(true, &bottom_event); | |
| 240 EXPECT_TRUE(root_window()->bounds().Contains(bottom_event.location())); | |
| 241 | |
| 242 // The locaion can be outside if |keep_inside_root| is false. | |
| 243 ui::MouseEvent bottom_event_outside(ui::ET_MOUSE_PRESSED, | |
| 244 bottom_edge_on_host, | |
| 245 bottom_edge_on_host, 0); | |
| 246 root_window()->TransformEventForDeviceScaleFactor(false, | |
| 247 &bottom_event_outside); | |
| 248 EXPECT_FALSE(root_window()->bounds().Contains( | |
| 249 bottom_event_outside.location())); | |
| 250 } | |
| 251 #endif | |
| 252 | |
| 253 namespace { | 212 namespace { |
| 254 | 213 |
| 255 class TestEventClient : public client::EventClient { | 214 class TestEventClient : public client::EventClient { |
| 256 public: | 215 public: |
| 257 static const int kNonLockWindowId = 100; | 216 static const int kNonLockWindowId = 100; |
| 258 static const int kLockWindowId = 200; | 217 static const int kLockWindowId = 200; |
| 259 | 218 |
| 260 explicit TestEventClient(RootWindow* root_window) | 219 explicit TestEventClient(RootWindow* root_window) |
| 261 : root_window_(root_window), | 220 : root_window_(root_window), |
| 262 lock_(false) { | 221 lock_(false) { |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 // Tap on w2 which triggers nested gestures for w1. | 786 // Tap on w2 which triggers nested gestures for w1. |
| 828 test::EventGenerator generator(root_window(), w2.get()); | 787 test::EventGenerator generator(root_window(), w2.get()); |
| 829 generator.GestureTapAt(w2->bounds().CenterPoint()); | 788 generator.GestureTapAt(w2->bounds().CenterPoint()); |
| 830 | 789 |
| 831 // Both windows should get their gesture end events. | 790 // Both windows should get their gesture end events. |
| 832 EXPECT_EQ(1, d1.gesture_end_count()); | 791 EXPECT_EQ(1, d1.gesture_end_count()); |
| 833 EXPECT_EQ(1, d2.gesture_end_count()); | 792 EXPECT_EQ(1, d2.gesture_end_count()); |
| 834 } | 793 } |
| 835 | 794 |
| 836 } // namespace aura | 795 } // namespace aura |
| OLD | NEW |