| 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 "components/view_manager/client_connection.h" | 9 #include "components/view_manager/client_connection.h" |
| 10 #include "components/view_manager/connection_manager.h" | 10 #include "components/view_manager/connection_manager.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 private: | 141 private: |
| 142 // ConnectionManagerDelegate: | 142 // ConnectionManagerDelegate: |
| 143 void OnLostConnectionToWindowManager() override {} | 143 void OnLostConnectionToWindowManager() override {} |
| 144 | 144 |
| 145 ClientConnection* CreateClientConnectionForEmbedAtView( | 145 ClientConnection* CreateClientConnectionForEmbedAtView( |
| 146 ConnectionManager* connection_manager, | 146 ConnectionManager* connection_manager, |
| 147 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, | 147 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, |
| 148 mojo::ConnectionSpecificId creator_id, | 148 mojo::ConnectionSpecificId creator_id, |
| 149 const std::string& creator_url, | 149 const std::string& creator_url, |
| 150 const std::string& url, | 150 mojo::URLRequestPtr request, |
| 151 const ViewId& root_id) override { | 151 const ViewId& root_id) override { |
| 152 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl( | 152 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl( |
| 153 connection_manager, creator_id, creator_url, url, root_id)); | 153 connection_manager, creator_id, creator_url, request->url, root_id)); |
| 154 last_connection_ = new TestClientConnection(service.Pass()); | 154 last_connection_ = new TestClientConnection(service.Pass()); |
| 155 return last_connection_; | 155 return last_connection_; |
| 156 } | 156 } |
| 157 ClientConnection* CreateClientConnectionForEmbedAtView( | 157 ClientConnection* CreateClientConnectionForEmbedAtView( |
| 158 ConnectionManager* connection_manager, | 158 ConnectionManager* connection_manager, |
| 159 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, | 159 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, |
| 160 mojo::ConnectionSpecificId creator_id, | 160 mojo::ConnectionSpecificId creator_id, |
| 161 const std::string& creator_url, | 161 const std::string& creator_url, |
| 162 const ViewId& root_id, | 162 const ViewId& root_id, |
| 163 mojo::ViewManagerClientPtr client) override { | 163 mojo::ViewManagerClientPtr client) override { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // 2,1 bounds=1,2 11x22 | 285 // 2,1 bounds=1,2 11x22 |
| 286 // 2,2 bounds=2,3 6x7 | 286 // 2,2 bounds=2,3 6x7 |
| 287 // 2,3 bounds=3,4 6x7 | 287 // 2,3 bounds=3,4 6x7 |
| 288 // CloneAndAnimate() is invoked for 2,2. | 288 // CloneAndAnimate() is invoked for 2,2. |
| 289 void SetUpAnimate1(ViewManagerServiceTest* test, ViewId* embed_view_id) { | 289 void SetUpAnimate1(ViewManagerServiceTest* test, ViewId* embed_view_id) { |
| 290 *embed_view_id = ViewId(test->wm_connection()->id(), 1); | 290 *embed_view_id = ViewId(test->wm_connection()->id(), 1); |
| 291 EXPECT_EQ(ERROR_CODE_NONE, test->wm_connection()->CreateView(*embed_view_id)); | 291 EXPECT_EQ(ERROR_CODE_NONE, test->wm_connection()->CreateView(*embed_view_id)); |
| 292 EXPECT_TRUE(test->wm_connection()->SetViewVisibility(*embed_view_id, true)); | 292 EXPECT_TRUE(test->wm_connection()->SetViewVisibility(*embed_view_id, true)); |
| 293 EXPECT_TRUE(test->wm_connection()->AddView(*(test->wm_connection()->root()), | 293 EXPECT_TRUE(test->wm_connection()->AddView(*(test->wm_connection()->root()), |
| 294 *embed_view_id)); | 294 *embed_view_id)); |
| 295 test->wm_connection()->EmbedUrl(std::string(), *embed_view_id, nullptr, | 295 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 296 nullptr); | 296 test->wm_connection()->EmbedRequest(request.Pass(), *embed_view_id, nullptr, |
| 297 nullptr); |
| 297 ViewManagerServiceImpl* connection1 = | 298 ViewManagerServiceImpl* connection1 = |
| 298 test->connection_manager()->GetConnectionWithRoot(*embed_view_id); | 299 test->connection_manager()->GetConnectionWithRoot(*embed_view_id); |
| 299 ASSERT_TRUE(connection1 != nullptr); | 300 ASSERT_TRUE(connection1 != nullptr); |
| 300 ASSERT_NE(connection1, test->wm_connection()); | 301 ASSERT_NE(connection1, test->wm_connection()); |
| 301 | 302 |
| 302 const ViewId child1(connection1->id(), 1); | 303 const ViewId child1(connection1->id(), 1); |
| 303 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); | 304 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); |
| 304 const ViewId child2(connection1->id(), 2); | 305 const ViewId child2(connection1->id(), 2); |
| 305 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); | 306 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); |
| 306 const ViewId child3(connection1->id(), 3); | 307 const ViewId child3(connection1->id(), 3); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 423 } |
| 423 | 424 |
| 424 // Clone and animate on a tree with more depth. Basically that of | 425 // Clone and animate on a tree with more depth. Basically that of |
| 425 // SetUpAnimate1() but cloning 2,1. | 426 // SetUpAnimate1() but cloning 2,1. |
| 426 TEST_F(ViewManagerServiceTest, CloneAndAnimateLargerDepth) { | 427 TEST_F(ViewManagerServiceTest, CloneAndAnimateLargerDepth) { |
| 427 const ViewId embed_view_id(wm_connection()->id(), 1); | 428 const ViewId embed_view_id(wm_connection()->id(), 1); |
| 428 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id)); | 429 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id)); |
| 429 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true)); | 430 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true)); |
| 430 EXPECT_TRUE( | 431 EXPECT_TRUE( |
| 431 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id)); | 432 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id)); |
| 432 wm_connection()->EmbedUrl(std::string(), embed_view_id, nullptr, nullptr); | 433 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 434 wm_connection()->EmbedRequest(request.Pass(), embed_view_id, nullptr, |
| 435 nullptr); |
| 433 ViewManagerServiceImpl* connection1 = | 436 ViewManagerServiceImpl* connection1 = |
| 434 connection_manager()->GetConnectionWithRoot(embed_view_id); | 437 connection_manager()->GetConnectionWithRoot(embed_view_id); |
| 435 ASSERT_TRUE(connection1 != nullptr); | 438 ASSERT_TRUE(connection1 != nullptr); |
| 436 ASSERT_NE(connection1, wm_connection()); | 439 ASSERT_NE(connection1, wm_connection()); |
| 437 | 440 |
| 438 const ViewId child1(connection1->id(), 1); | 441 const ViewId child1(connection1->id(), 1); |
| 439 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); | 442 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1)); |
| 440 const ViewId child2(connection1->id(), 2); | 443 const ViewId child2(connection1->id(), 2); |
| 441 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); | 444 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2)); |
| 442 const ViewId child3(connection1->id(), 3); | 445 const ViewId child3(connection1->id(), 3); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 469 } | 472 } |
| 470 | 473 |
| 471 // Verifies focus correctly changes on pointer events. | 474 // Verifies focus correctly changes on pointer events. |
| 472 TEST_F(ViewManagerServiceTest, FocusOnPointer) { | 475 TEST_F(ViewManagerServiceTest, FocusOnPointer) { |
| 473 const ViewId embed_view_id(wm_connection()->id(), 1); | 476 const ViewId embed_view_id(wm_connection()->id(), 1); |
| 474 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id)); | 477 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id)); |
| 475 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true)); | 478 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true)); |
| 476 EXPECT_TRUE( | 479 EXPECT_TRUE( |
| 477 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id)); | 480 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id)); |
| 478 connection_manager()->root()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 481 connection_manager()->root()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 479 wm_connection()->EmbedUrl(std::string(), embed_view_id, nullptr, nullptr); | 482 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
| 483 wm_connection()->EmbedRequest(request.Pass(), embed_view_id, nullptr, |
| 484 nullptr); |
| 480 ViewManagerServiceImpl* connection1 = | 485 ViewManagerServiceImpl* connection1 = |
| 481 connection_manager()->GetConnectionWithRoot(embed_view_id); | 486 connection_manager()->GetConnectionWithRoot(embed_view_id); |
| 482 ASSERT_TRUE(connection1 != nullptr); | 487 ASSERT_TRUE(connection1 != nullptr); |
| 483 ASSERT_NE(connection1, wm_connection()); | 488 ASSERT_NE(connection1, wm_connection()); |
| 484 | 489 |
| 485 connection_manager() | 490 connection_manager() |
| 486 ->GetView(embed_view_id) | 491 ->GetView(embed_view_id) |
| 487 ->SetBounds(gfx::Rect(0, 0, 50, 50)); | 492 ->SetBounds(gfx::Rect(0, 0, 50, 50)); |
| 488 | 493 |
| 489 const ViewId child1(connection1->id(), 1); | 494 const ViewId child1(connection1->id(), 1); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 EXPECT_EQ(connection_manager()->root(), | 542 EXPECT_EQ(connection_manager()->root(), |
| 538 connection_manager()->GetFocusedView()); | 543 connection_manager()->GetFocusedView()); |
| 539 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u); | 544 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u); |
| 540 EXPECT_EQ("InputEvent view=0,1 event_action=4", | 545 EXPECT_EQ("InputEvent view=0,1 event_action=4", |
| 541 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 546 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
| 542 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); | 547 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); |
| 543 ; | 548 ; |
| 544 } | 549 } |
| 545 | 550 |
| 546 } // namespace view_manager | 551 } // namespace view_manager |
| OLD | NEW |