OLD | NEW |
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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
10 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 10 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "services/view_manager/server_view.h" | 21 #include "services/view_manager/server_view.h" |
22 #include "services/view_manager/test_change_tracker.h" | 22 #include "services/view_manager/test_change_tracker.h" |
23 #include "services/view_manager/view_manager_service_impl.h" | 23 #include "services/view_manager/view_manager_service_impl.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
26 | 26 |
27 using mojo::Array; | 27 using mojo::Array; |
28 using mojo::ERROR_CODE_NONE; | 28 using mojo::ERROR_CODE_NONE; |
29 using mojo::InterfaceRequest; | 29 using mojo::InterfaceRequest; |
30 using mojo::ServiceProvider; | 30 using mojo::ServiceProvider; |
| 31 using mojo::ServiceProviderPtr; |
31 using mojo::String; | 32 using mojo::String; |
32 using mojo::ViewDataPtr; | 33 using mojo::ViewDataPtr; |
33 | 34 |
34 namespace view_manager { | 35 namespace view_manager { |
35 namespace { | 36 namespace { |
36 | 37 |
37 // ----------------------------------------------------------------------------- | 38 // ----------------------------------------------------------------------------- |
38 | 39 |
39 // ViewManagerClient implementation that logs all calls to a TestChangeTracker. | 40 // ViewManagerClient implementation that logs all calls to a TestChangeTracker. |
40 // TODO(sky): refactor so both this and ViewManagerServiceAppTest share code. | 41 // TODO(sky): refactor so both this and ViewManagerServiceAppTest share code. |
41 class TestViewManagerClient : public mojo::ViewManagerClient { | 42 class TestViewManagerClient : public mojo::ViewManagerClient { |
42 public: | 43 public: |
43 TestViewManagerClient() {} | 44 TestViewManagerClient() {} |
44 ~TestViewManagerClient() override {} | 45 ~TestViewManagerClient() override {} |
45 | 46 |
46 TestChangeTracker* tracker() { return &tracker_; } | 47 TestChangeTracker* tracker() { return &tracker_; } |
47 | 48 |
48 private: | 49 private: |
49 // ViewManagerClient: | 50 // ViewManagerClient: |
50 void OnEmbed(uint16_t connection_id, | 51 void OnEmbed(uint16_t connection_id, |
51 const String& embedder_url, | 52 const String& embedder_url, |
52 ViewDataPtr root, | 53 ViewDataPtr root, |
53 InterfaceRequest<ServiceProvider> parent_service_provider, | 54 InterfaceRequest<ServiceProvider> services, |
| 55 ServiceProviderPtr exposed_services, |
54 mojo::ScopedMessagePipeHandle window_manager_pipe) override { | 56 mojo::ScopedMessagePipeHandle window_manager_pipe) override { |
55 tracker_.OnEmbed(connection_id, embedder_url, root.Pass()); | 57 tracker_.OnEmbed(connection_id, embedder_url, root.Pass()); |
56 } | 58 } |
57 void OnEmbeddedAppDisconnected(uint32_t view) override { | 59 void OnEmbeddedAppDisconnected(uint32_t view) override { |
58 tracker_.OnEmbeddedAppDisconnected(view); | 60 tracker_.OnEmbeddedAppDisconnected(view); |
59 } | 61 } |
60 void OnViewBoundsChanged(uint32_t view, | 62 void OnViewBoundsChanged(uint32_t view, |
61 mojo::RectPtr old_bounds, | 63 mojo::RectPtr old_bounds, |
62 mojo::RectPtr new_bounds) override { | 64 mojo::RectPtr new_bounds) override { |
63 tracker_.OnViewBoundsChanged(view, old_bounds.Pass(), new_bounds.Pass()); | 65 tracker_.OnViewBoundsChanged(view, old_bounds.Pass(), new_bounds.Pass()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 // 2,1 bounds=1,2 11x22 | 265 // 2,1 bounds=1,2 11x22 |
264 // 2,2 bounds=2,3 6x7 | 266 // 2,2 bounds=2,3 6x7 |
265 // 2,3 bounds=3,4 6x7 | 267 // 2,3 bounds=3,4 6x7 |
266 // CloneAndAnimate() is invoked for 2,2. | 268 // CloneAndAnimate() is invoked for 2,2. |
267 void SetUpAnimate1(ViewManagerServiceTest* test, ViewId* embed_view_id) { | 269 void SetUpAnimate1(ViewManagerServiceTest* test, ViewId* embed_view_id) { |
268 *embed_view_id = ViewId(test->wm_connection()->id(), 1); | 270 *embed_view_id = ViewId(test->wm_connection()->id(), 1); |
269 EXPECT_EQ(ERROR_CODE_NONE, test->wm_connection()->CreateView(*embed_view_id)); | 271 EXPECT_EQ(ERROR_CODE_NONE, test->wm_connection()->CreateView(*embed_view_id)); |
270 EXPECT_TRUE(test->wm_connection()->SetViewVisibility(*embed_view_id, true)); | 272 EXPECT_TRUE(test->wm_connection()->SetViewVisibility(*embed_view_id, true)); |
271 EXPECT_TRUE(test->wm_connection()->AddView(*(test->wm_connection()->root()), | 273 EXPECT_TRUE(test->wm_connection()->AddView(*(test->wm_connection()->root()), |
272 *embed_view_id)); | 274 *embed_view_id)); |
273 EXPECT_TRUE(test->wm_connection()->Embed( | 275 test->wm_connection()->Embed(std::string(), *embed_view_id, nullptr, nullptr); |
274 std::string(), *embed_view_id, InterfaceRequest<ServiceProvider>())); | |
275 ViewManagerServiceImpl* connection1 = | 276 ViewManagerServiceImpl* connection1 = |
276 test->connection_manager()->GetConnectionWithRoot(*embed_view_id); | 277 test->connection_manager()->GetConnectionWithRoot(*embed_view_id); |
277 ASSERT_TRUE(connection1 != nullptr); | 278 ASSERT_TRUE(connection1 != nullptr); |
278 ASSERT_NE(connection1, test->wm_connection()); | 279 ASSERT_NE(connection1, test->wm_connection()); |
279 | 280 |
280 const ViewId child1(connection1->id(), 1); | 281 const ViewId child1(connection1->id(), 1); |
281 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); | 282 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); |
282 const ViewId child2(connection1->id(), 2); | 283 const ViewId child2(connection1->id(), 2); |
283 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); | 284 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); |
284 const ViewId child3(connection1->id(), 3); | 285 const ViewId child3(connection1->id(), 3); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 401 } |
401 | 402 |
402 // Clone and animate on a tree with more depth. Basically that of | 403 // Clone and animate on a tree with more depth. Basically that of |
403 // SetUpAnimate1() but cloning 2,1. | 404 // SetUpAnimate1() but cloning 2,1. |
404 TEST_F(ViewManagerServiceTest, CloneAndAnimateLargerDepth) { | 405 TEST_F(ViewManagerServiceTest, CloneAndAnimateLargerDepth) { |
405 const ViewId embed_view_id(wm_connection()->id(), 1); | 406 const ViewId embed_view_id(wm_connection()->id(), 1); |
406 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id)); | 407 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id)); |
407 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true)); | 408 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true)); |
408 EXPECT_TRUE( | 409 EXPECT_TRUE( |
409 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id)); | 410 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id)); |
410 EXPECT_TRUE(wm_connection()->Embed(std::string(), embed_view_id, | 411 wm_connection()->Embed(std::string(), embed_view_id, nullptr, nullptr); |
411 InterfaceRequest<ServiceProvider>())); | |
412 ViewManagerServiceImpl* connection1 = | 412 ViewManagerServiceImpl* connection1 = |
413 connection_manager()->GetConnectionWithRoot(embed_view_id); | 413 connection_manager()->GetConnectionWithRoot(embed_view_id); |
414 ASSERT_TRUE(connection1 != nullptr); | 414 ASSERT_TRUE(connection1 != nullptr); |
415 ASSERT_NE(connection1, wm_connection()); | 415 ASSERT_NE(connection1, wm_connection()); |
416 | 416 |
417 const ViewId child1(connection1->id(), 1); | 417 const ViewId child1(connection1->id(), 1); |
418 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); | 418 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); |
419 const ViewId child2(connection1->id(), 2); | 419 const ViewId child2(connection1->id(), 2); |
420 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); | 420 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); |
421 const ViewId child3(connection1->id(), 3); | 421 const ViewId child3(connection1->id(), 3); |
(...skipping 19 matching lines...) Expand all Loading... |
441 const ServerView* cloned_view = GetFirstCloned(v1->parent()); | 441 const ServerView* cloned_view = GetFirstCloned(v1->parent()); |
442 ASSERT_TRUE(cloned_view); | 442 ASSERT_TRUE(cloned_view); |
443 // |cloned_view| should have a child and its child should have a child. | 443 // |cloned_view| should have a child and its child should have a child. |
444 ASSERT_EQ(1u, cloned_view->GetChildren().size()); | 444 ASSERT_EQ(1u, cloned_view->GetChildren().size()); |
445 const ServerView* cloned_view_child = cloned_view->GetChildren()[0]; | 445 const ServerView* cloned_view_child = cloned_view->GetChildren()[0]; |
446 EXPECT_EQ(1u, cloned_view_child->GetChildren().size()); | 446 EXPECT_EQ(1u, cloned_view_child->GetChildren().size()); |
447 EXPECT_TRUE(cloned_view_child->id() == ClonedViewId()); | 447 EXPECT_TRUE(cloned_view_child->id() == ClonedViewId()); |
448 } | 448 } |
449 | 449 |
450 } // namespace view_manager | 450 } // namespace view_manager |
OLD | NEW |