Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: ui/aura/root_window_unittest.cc

Issue 12423007: Short term workaround to deal with calculation error caused by inverted matrix. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix argument order Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/aura/test/event_generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/focus_manager.h" 12 #include "ui/aura/focus_manager.h"
13 #include "ui/aura/test/aura_test_base.h" 13 #include "ui/aura/test/aura_test_base.h"
14 #include "ui/aura/test/event_generator.h" 14 #include "ui/aura/test/event_generator.h"
15 #include "ui/aura/test/test_event_handler.h" 15 #include "ui/aura/test/test_event_handler.h"
16 #include "ui/aura/test/test_window_delegate.h" 16 #include "ui/aura/test/test_window_delegate.h"
17 #include "ui/aura/test/test_windows.h" 17 #include "ui/aura/test/test_windows.h"
18 #include "ui/aura/window_tracker.h" 18 #include "ui/aura/window_tracker.h"
19 #include "ui/base/events/event.h" 19 #include "ui/base/events/event.h"
20 #include "ui/base/events/event_handler.h" 20 #include "ui/base/events/event_handler.h"
21 #include "ui/base/events/event_utils.h" 21 #include "ui/base/events/event_utils.h"
22 #include "ui/base/gestures/gesture_configuration.h" 22 #include "ui/base/gestures/gesture_configuration.h"
23 #include "ui/base/hit_test.h" 23 #include "ui/base/hit_test.h"
24 #include "ui/base/keycodes/keyboard_codes.h" 24 #include "ui/base/keycodes/keyboard_codes.h"
25 #include "ui/gfx/point.h" 25 #include "ui/gfx/point.h"
26 #include "ui/gfx/rect.h" 26 #include "ui/gfx/rect.h"
27 #include "ui/gfx/screen.h" 27 #include "ui/gfx/screen.h"
28 #include "ui/gfx/transform.h"
28 29
29 namespace aura { 30 namespace aura {
30 namespace { 31 namespace {
31 32
32 // A delegate that always returns a non-client component for hit tests. 33 // A delegate that always returns a non-client component for hit tests.
33 class NonClientDelegate : public test::TestWindowDelegate { 34 class NonClientDelegate : public test::TestWindowDelegate {
34 public: 35 public:
35 NonClientDelegate() 36 NonClientDelegate()
36 : non_client_count_(0), 37 : non_client_count_(0),
37 mouse_event_count_(0), 38 mouse_event_count_(0),
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 EXPECT_EQ("100,100", root.location().ToString()); 202 EXPECT_EQ("100,100", root.location().ToString());
202 EXPECT_EQ("100,100", root.root_location().ToString()); 203 EXPECT_EQ("100,100", root.root_location().ToString());
203 204
204 ui::MouseEvent translated_event( 205 ui::MouseEvent translated_event(
205 root, static_cast<Window*>(root_window()), w1.get(), 206 root, static_cast<Window*>(root_window()), w1.get(),
206 ui::ET_MOUSE_ENTERED, root.flags()); 207 ui::ET_MOUSE_ENTERED, root.flags());
207 EXPECT_EQ("50,50", translated_event.location().ToString()); 208 EXPECT_EQ("50,50", translated_event.location().ToString());
208 EXPECT_EQ("100,100", translated_event.root_location().ToString()); 209 EXPECT_EQ("100,100", translated_event.root_location().ToString());
209 } 210 }
210 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
211 namespace { 253 namespace {
212 254
213 class TestEventClient : public client::EventClient { 255 class TestEventClient : public client::EventClient {
214 public: 256 public:
215 static const int kNonLockWindowId = 100; 257 static const int kNonLockWindowId = 100;
216 static const int kLockWindowId = 200; 258 static const int kLockWindowId = 200;
217 259
218 explicit TestEventClient(RootWindow* root_window) 260 explicit TestEventClient(RootWindow* root_window)
219 : root_window_(root_window), 261 : root_window_(root_window),
220 lock_(false) { 262 lock_(false) {
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 // Tap on w2 which triggers nested gestures for w1. 827 // Tap on w2 which triggers nested gestures for w1.
786 test::EventGenerator generator(root_window(), w2.get()); 828 test::EventGenerator generator(root_window(), w2.get());
787 generator.GestureTapAt(w2->bounds().CenterPoint()); 829 generator.GestureTapAt(w2->bounds().CenterPoint());
788 830
789 // Both windows should get their gesture end events. 831 // Both windows should get their gesture end events.
790 EXPECT_EQ(1, d1.gesture_end_count()); 832 EXPECT_EQ(1, d1.gesture_end_count());
791 EXPECT_EQ(1, d2.gesture_end_count()); 833 EXPECT_EQ(1, d2.gesture_end_count());
792 } 834 }
793 835
794 } // namespace aura 836 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/aura/test/event_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698