diff options
author | John Abd-El-Malek <jam@chromium.org> | 2015-04-02 10:29:35 -0700 |
---|---|---|
committer | John Abd-El-Malek <jam@chromium.org> | 2015-04-02 17:31:11 +0000 |
commit | 537a670451020f4764d511cbdf8e30ec91ef897c (patch) | |
tree | d2868da2b0d33dc7ed8c8e709ae4a7f5bd5aefd8 /mojo/services/window_manager/view_target_unittest.cc | |
parent | 83653dd1da59dfa7ddd9e48d4cd507a11cefd968 (diff) | |
download | chromium_src-537a670451020f4764d511cbdf8e30ec91ef897c.zip chromium_src-537a670451020f4764d511cbdf8e30ec91ef897c.tar.gz chromium_src-537a670451020f4764d511cbdf8e30ec91ef897c.tar.bz2 |
Get mojo_shell building inside chromium checkout.
This brings in mojo_shell and the necessary services to make html_viewer work.
This is copied from the Mojo repo at 272fbba5887d66fc0111e2ab44c1edf67b7f23e0.
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/1049993002
Cr-Commit-Position: refs/heads/master@{#323528}
Diffstat (limited to 'mojo/services/window_manager/view_target_unittest.cc')
-rw-r--r-- | mojo/services/window_manager/view_target_unittest.cc | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/mojo/services/window_manager/view_target_unittest.cc b/mojo/services/window_manager/view_target_unittest.cc new file mode 100644 index 0000000..bec5c37 --- /dev/null +++ b/mojo/services/window_manager/view_target_unittest.cc @@ -0,0 +1,81 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/services/window_manager/view_target.h" + +#include <set> + +#include "mojo/services/window_manager/window_manager_test_util.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/mojo_services/src/view_manager/public/cpp/view.h" +#include "ui/gfx/geometry/rect.h" + +namespace window_manager { + +using ViewTargetTest = testing::Test; + +// V1 +// +-- V2 +// +-- V3 +TEST_F(ViewTargetTest, GetRoot) { + TestView v1(1, gfx::Rect(20, 20, 400, 400)); + TestView v2(2, gfx::Rect(10, 10, 350, 350)); + TestView v3(3, gfx::Rect(10, 10, 100, 100)); + v1.AddChild(&v2); + v2.AddChild(&v3); + + EXPECT_EQ(ViewTarget::TargetFromView(&v1), + ViewTarget::TargetFromView(&v1)->GetRoot()); + EXPECT_EQ(ViewTarget::TargetFromView(&v1), + ViewTarget::TargetFromView(&v2)->GetRoot()); + EXPECT_EQ(ViewTarget::TargetFromView(&v1), + ViewTarget::TargetFromView(&v3)->GetRoot()); +} + +// V1 +// +-- V2 +TEST_F(ViewTargetTest, ConvertPointToTarget_Simple) { + TestView v1(1, gfx::Rect(20, 20, 400, 400)); + TestView v2(2, gfx::Rect(10, 10, 350, 350)); + v1.AddChild(&v2); + + ViewTarget* t1 = v1.target(); + ViewTarget* t2 = v2.target(); + + gfx::Point point1_in_t2_coords(5, 5); + ViewTarget::ConvertPointToTarget(t2, t1, &point1_in_t2_coords); + gfx::Point point1_in_t1_coords(15, 15); + EXPECT_EQ(point1_in_t1_coords, point1_in_t2_coords); + + gfx::Point point2_in_t1_coords(5, 5); + ViewTarget::ConvertPointToTarget(t1, t2, &point2_in_t1_coords); + gfx::Point point2_in_t2_coords(-5, -5); + EXPECT_EQ(point2_in_t2_coords, point2_in_t1_coords); +} + +// V1 +// +-- V2 +// +-- V3 +TEST_F(ViewTargetTest, ConvertPointToTarget_Medium) { + TestView v1(1, gfx::Rect(20, 20, 400, 400)); + TestView v2(2, gfx::Rect(10, 10, 350, 350)); + TestView v3(3, gfx::Rect(10, 10, 100, 100)); + v1.AddChild(&v2); + v2.AddChild(&v3); + + ViewTarget* t1 = v1.target(); + ViewTarget* t3 = v3.target(); + + gfx::Point point1_in_t3_coords(5, 5); + ViewTarget::ConvertPointToTarget(t3, t1, &point1_in_t3_coords); + gfx::Point point1_in_t1_coords(25, 25); + EXPECT_EQ(point1_in_t1_coords, point1_in_t3_coords); + + gfx::Point point2_in_t1_coords(5, 5); + ViewTarget::ConvertPointToTarget(t1, t3, &point2_in_t1_coords); + gfx::Point point2_in_t3_coords(-15, -15); + EXPECT_EQ(point2_in_t3_coords, point2_in_t1_coords); +} + +} // namespace window_manager |