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

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

Issue 10543174: Aura: Add Window::MoveCursorTo() taking relative location to the window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test. Created 8 years, 6 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/window.cc ('k') | no next file » | 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/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Window::ConvertPointToWindow is mostly identical to 295 // Window::ConvertPointToWindow is mostly identical to
296 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted, 296 // Layer::ConvertPointToLayer, except NULL values for |source| are permitted,
297 // in which case the function just returns. 297 // in which case the function just returns.
298 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); 298 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL));
299 gfx::Point reference_point(100, 100); 299 gfx::Point reference_point(100, 100);
300 gfx::Point test_point = reference_point; 300 gfx::Point test_point = reference_point;
301 Window::ConvertPointToWindow(NULL, w1.get(), &test_point); 301 Window::ConvertPointToWindow(NULL, w1.get(), &test_point);
302 EXPECT_EQ(reference_point, test_point); 302 EXPECT_EQ(reference_point, test_point);
303 } 303 }
304 304
305 TEST_F(WindowTest, MoveCursorTo) {
306 scoped_ptr<Window> w1(
307 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL));
308 scoped_ptr<Window> w11(
309 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get()));
310 scoped_ptr<Window> w111(
311 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get()));
312 scoped_ptr<Window> w1111(
313 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get()));
314
315 RootWindow* root = root_window();
316 root->MoveCursorTo(gfx::Point(10, 10));
317 EXPECT_EQ(gfx::Point(10, 10), root->last_mouse_location());
318 w1->MoveCursorTo(gfx::Point(10, 10));
319 EXPECT_EQ(gfx::Point(20, 20), root->last_mouse_location());
320 w11->MoveCursorTo(gfx::Point(10, 10));
321 EXPECT_EQ(gfx::Point(25, 25), root->last_mouse_location());
322 w111->MoveCursorTo(gfx::Point(10, 10));
323 EXPECT_EQ(gfx::Point(30, 30), root->last_mouse_location());
324 w1111->MoveCursorTo(gfx::Point(10, 10));
325 EXPECT_EQ(gfx::Point(35, 35), root->last_mouse_location());
oshima 2012/06/15 14:06:17 can you also add cases that applies transforms (ro
yoshiki 2012/06/15 15:10:39 Done.
326 }
327
305 TEST_F(WindowTest, HitTest) { 328 TEST_F(WindowTest, HitTest) {
306 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); 329 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE));
307 w1.set_id(1); 330 w1.set_id(1);
308 w1.Init(ui::LAYER_TEXTURED); 331 w1.Init(ui::LAYER_TEXTURED);
309 w1.SetBounds(gfx::Rect(10, 20, 50, 60)); 332 w1.SetBounds(gfx::Rect(10, 20, 50, 60));
310 w1.Show(); 333 w1.Show();
311 w1.SetParent(NULL); 334 w1.SetParent(NULL);
312 335
313 // Points are in the Window's coordinates. 336 // Points are in the Window's coordinates.
314 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1))); 337 EXPECT_TRUE(w1.HitTest(gfx::Point(1, 1)));
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000)); 2312 element->Step(start_time + base::TimeDelta::FromMilliseconds(1000));
2290 2313
2291 // No bounds changed notification at the end of animation since layer 2314 // No bounds changed notification at the end of animation since layer
2292 // delegate is NULL. 2315 // delegate is NULL.
2293 EXPECT_FALSE(delegate.bounds_changed()); 2316 EXPECT_FALSE(delegate.bounds_changed());
2294 EXPECT_NE("0,0 100x100", window->bounds().ToString()); 2317 EXPECT_NE("0,0 100x100", window->bounds().ToString());
2295 } 2318 }
2296 2319
2297 } // namespace test 2320 } // namespace test
2298 } // namespace aura 2321 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698