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

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

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

Powered by Google App Engine
This is Rietveld 408576698