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

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

Issue 11359172: ui: Remove implicit flooring in skia rect conversion methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make root window transform in tests produce an integer result Created 8 years, 1 month 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/compositor/layer_unittest.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/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 scoped_ptr<Window> w1( 414 scoped_ptr<Window> w1(
415 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); 415 CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL));
416 scoped_ptr<Window> w11( 416 scoped_ptr<Window> w11(
417 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); 417 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get()));
418 scoped_ptr<Window> w111( 418 scoped_ptr<Window> w111(
419 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); 419 CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get()));
420 scoped_ptr<Window> w1111( 420 scoped_ptr<Window> w1111(
421 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); 421 CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get()));
422 422
423 RootWindow* root = root_window(); 423 RootWindow* root = root_window();
424
425 // The root window expects transforms that produce integer rects.
426 gfx::Transform root_transform;
427 root_transform.ConcatScale(2.0f, 3.0f);
428 root_transform.ConcatTranslate(-50, -50);
429 root_transform.ConcatRotate(-90.0f);
430 root_transform.ConcatTranslate(60, 70);
431
424 gfx::Transform transform; 432 gfx::Transform transform;
425 transform.ConcatScale(0.3f, 0.5f); 433 transform.ConcatScale(0.3f, 0.5f);
426 transform.ConcatRotate(10.0f); 434 transform.ConcatRotate(10.0f);
427 transform.ConcatTranslate(10, 20); 435 transform.ConcatTranslate(10, 20);
428 436
429 root->SetTransform(transform); 437 root->SetTransform(root_transform);
430 w1->SetTransform(transform); 438 w1->SetTransform(transform);
431 w11->SetTransform(transform); 439 w11->SetTransform(transform);
432 w111->SetTransform(transform); 440 w111->SetTransform(transform);
433 w1111->SetTransform(transform); 441 w1111->SetTransform(transform);
434 442
435 w1111->MoveCursorTo(gfx::Point(10, 10)); 443 w1111->MoveCursorTo(gfx::Point(10, 10));
436 444
437 #if !defined(OS_WIN) 445 #if !defined(OS_WIN)
438 // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.OD 446 // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.
439 EXPECT_EQ("11,47", root->QueryMouseLocationForTest().ToString()); 447 EXPECT_EQ("169,80", root->QueryMouseLocationForTest().ToString());
440 #endif 448 #endif
441 EXPECT_EQ("20,53", 449 EXPECT_EQ("20,53",
442 gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); 450 gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString());
443 } 451 }
444 452
445 TEST_F(WindowTest, HitTest) { 453 TEST_F(WindowTest, HitTest) {
446 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); 454 Window w1(new ColorTestWindowDelegate(SK_ColorWHITE));
447 w1.set_id(1); 455 w1.set_id(1);
448 w1.Init(ui::LAYER_TEXTURED); 456 w1.Init(ui::LAYER_TEXTURED);
449 w1.SetBounds(gfx::Rect(10, 20, 50, 60)); 457 w1.SetBounds(gfx::Rect(10, 20, 50, 60));
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 // Move |w2| to be a child of |w1|. 2559 // Move |w2| to be a child of |w1|.
2552 w1->AddChild(w2.get()); 2560 w1->AddChild(w2.get());
2553 // Sine we moved in the same root, observer shouldn't be notified. 2561 // Sine we moved in the same root, observer shouldn't be notified.
2554 EXPECT_EQ("0 0", observer.CountStringAndReset()); 2562 EXPECT_EQ("0 0", observer.CountStringAndReset());
2555 // |w2| should still have focus after moving. 2563 // |w2| should still have focus after moving.
2556 EXPECT_TRUE(w2->HasFocus()); 2564 EXPECT_TRUE(w2->HasFocus());
2557 } 2565 }
2558 2566
2559 } // namespace test 2567 } // namespace test
2560 } // namespace aura 2568 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window.cc ('k') | ui/compositor/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698