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

Side by Side Diff: services/view_manager/view_coordinate_conversions_unittest.cc

Issue 772893004: Adds constants and runner for animations (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: tweaks Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/view_manager/server_view.h" 5 #include "services/view_manager/server_view.h"
6 #include "services/view_manager/server_view_delegate.h" 6 #include "services/view_manager/server_view_delegate.h"
7 #include "services/view_manager/test_server_view_delegate.h"
7 #include "services/view_manager/view_coordinate_conversions.h" 8 #include "services/view_manager/view_coordinate_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/vector2d.h" 11 #include "ui/gfx/geometry/vector2d.h"
11 12
12 namespace mojo { 13 namespace mojo {
13 namespace service { 14 namespace service {
14 namespace {
15
16 class MockServerViewDelegate : public ServerViewDelegate {
17 public:
18 MockServerViewDelegate() {}
19 ~MockServerViewDelegate() override {}
20
21 private:
22 // ServerViewDelegate:
23 void OnWillDestroyView(ServerView* view) override {}
24 void OnViewDestroyed(const ServerView* view) override {}
25 void OnWillChangeViewHierarchy(ServerView* view,
26 ServerView* new_parent,
27 ServerView* old_parent) override {}
28 void OnViewHierarchyChanged(const ServerView* view,
29 const ServerView* new_parent,
30 const ServerView* old_parent) override {}
31 void OnViewBoundsChanged(const ServerView* view,
32 const gfx::Rect& old_bounds,
33 const gfx::Rect& new_bounds) override {}
34 void OnViewSurfaceIdChanged(const ServerView* view) override {}
35 void OnViewReordered(const ServerView* view,
36 const ServerView* relative,
37 OrderDirection direction) override {}
38 void OnWillChangeViewVisibility(ServerView* view) override {}
39 void OnViewSharedPropertyChanged(
40 const ServerView* view,
41 const std::string& name,
42 const std::vector<uint8_t>* new_data) override {}
43 void OnScheduleViewPaint(const ServerView* view) override {}
44
45 DISALLOW_COPY_AND_ASSIGN(MockServerViewDelegate);
46 };
47
48 } // namespace
49 15
50 using ViewCoordinateConversionsTest = testing::Test; 16 using ViewCoordinateConversionsTest = testing::Test;
51 17
52 TEST_F(ViewCoordinateConversionsTest, ConvertRectBetweenViews) { 18 TEST_F(ViewCoordinateConversionsTest, ConvertRectBetweenViews) {
53 MockServerViewDelegate d1, d2, d3; 19 TestServerViewDelegate d1, d2, d3;
54 ServerView v1(&d1, ViewId()), v2(&d2, ViewId()), v3(&d3, ViewId()); 20 ServerView v1(&d1, ViewId()), v2(&d2, ViewId()), v3(&d3, ViewId());
55 v1.SetBounds(gfx::Rect(1, 2, 100, 100)); 21 v1.SetBounds(gfx::Rect(1, 2, 100, 100));
56 v2.SetBounds(gfx::Rect(3, 4, 100, 100)); 22 v2.SetBounds(gfx::Rect(3, 4, 100, 100));
57 v3.SetBounds(gfx::Rect(5, 6, 100, 100)); 23 v3.SetBounds(gfx::Rect(5, 6, 100, 100));
58 v1.Add(&v2); 24 v1.Add(&v2);
59 v2.Add(&v3); 25 v2.Add(&v3);
60 26
61 EXPECT_EQ(gfx::Rect(2, 1, 8, 9), 27 EXPECT_EQ(gfx::Rect(2, 1, 8, 9),
62 ConvertRectBetweenViews(&v1, &v3, gfx::Rect(10, 11, 8, 9))); 28 ConvertRectBetweenViews(&v1, &v3, gfx::Rect(10, 11, 8, 9)));
63 29
64 EXPECT_EQ(gfx::Rect(18, 21, 8, 9), 30 EXPECT_EQ(gfx::Rect(18, 21, 8, 9),
65 ConvertRectBetweenViews(&v3, &v1, gfx::Rect(10, 11, 8, 9))); 31 ConvertRectBetweenViews(&v3, &v1, gfx::Rect(10, 11, 8, 9)));
66 } 32 }
67 33
68 } // namespace service 34 } // namespace service
69 } // namespace mojo 35 } // namespace mojo
OLDNEW
« services/view_manager/server_view.h ('K') | « services/view_manager/test_server_view_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698