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/mus/common/types.h" | 9 #include "components/mus/common/types.h" |
10 #include "components/mus/common/util.h" | 10 #include "components/mus/common/util.h" |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 TestWindowTreeHostConnection* host_connection_; | 347 TestWindowTreeHostConnection* host_connection_; |
348 scoped_ptr<ConnectionManager> connection_manager_; | 348 scoped_ptr<ConnectionManager> connection_manager_; |
349 base::MessageLoop message_loop_; | 349 base::MessageLoop message_loop_; |
350 | 350 |
351 DISALLOW_COPY_AND_ASSIGN(WindowTreeTest); | 351 DISALLOW_COPY_AND_ASSIGN(WindowTreeTest); |
352 }; | 352 }; |
353 | 353 |
354 // Verifies focus correctly changes on pointer events. | 354 // Verifies focus correctly changes on pointer events. |
355 TEST_F(WindowTreeTest, FocusOnPointer) { | 355 TEST_F(WindowTreeTest, FocusOnPointer) { |
356 const WindowId embed_window_id(wm_connection()->id(), 1); | 356 const WindowId embed_window_id(wm_connection()->id(), 1); |
357 EXPECT_TRUE(wm_connection()->NewWindow(embed_window_id)); | 357 EXPECT_TRUE( |
| 358 wm_connection()->NewWindow(embed_window_id, ServerWindow::Properties())); |
358 EXPECT_TRUE(wm_connection()->SetWindowVisibility(embed_window_id, true)); | 359 EXPECT_TRUE(wm_connection()->SetWindowVisibility(embed_window_id, true)); |
359 EXPECT_TRUE( | 360 EXPECT_TRUE( |
360 wm_connection()->AddWindow(*(wm_connection()->root()), embed_window_id)); | 361 wm_connection()->AddWindow(*(wm_connection()->root()), embed_window_id)); |
361 host_connection()->window_tree_host()->root_window()->SetBounds( | 362 host_connection()->window_tree_host()->root_window()->SetBounds( |
362 gfx::Rect(0, 0, 100, 100)); | 363 gfx::Rect(0, 0, 100, 100)); |
363 mojom::WindowTreeClientPtr client; | 364 mojom::WindowTreeClientPtr client; |
364 mojo::InterfaceRequest<mojom::WindowTreeClient> client_request = | 365 mojo::InterfaceRequest<mojom::WindowTreeClient> client_request = |
365 GetProxy(&client); | 366 GetProxy(&client); |
366 wm_client()->Bind(client_request.Pass()); | 367 wm_client()->Bind(client_request.Pass()); |
367 ConnectionSpecificId connection_id = 0; | 368 ConnectionSpecificId connection_id = 0; |
368 wm_connection()->Embed(embed_window_id, | 369 wm_connection()->Embed(embed_window_id, |
369 client.Pass(), | 370 client.Pass(), |
370 mojom::WindowTree::ACCESS_POLICY_DEFAULT, | 371 mojom::WindowTree::ACCESS_POLICY_DEFAULT, |
371 &connection_id); | 372 &connection_id); |
372 WindowTreeImpl* connection1 = | 373 WindowTreeImpl* connection1 = |
373 connection_manager()->GetConnectionWithRoot(embed_window_id); | 374 connection_manager()->GetConnectionWithRoot(embed_window_id); |
374 ASSERT_TRUE(connection1 != nullptr); | 375 ASSERT_TRUE(connection1 != nullptr); |
375 ASSERT_NE(connection1, wm_connection()); | 376 ASSERT_NE(connection1, wm_connection()); |
376 | 377 |
377 connection_manager() | 378 connection_manager() |
378 ->GetWindow(embed_window_id) | 379 ->GetWindow(embed_window_id) |
379 ->SetBounds(gfx::Rect(0, 0, 50, 50)); | 380 ->SetBounds(gfx::Rect(0, 0, 50, 50)); |
380 | 381 |
381 const WindowId child1(connection1->id(), 1); | 382 const WindowId child1(connection1->id(), 1); |
382 EXPECT_TRUE(connection1->NewWindow(child1)); | 383 EXPECT_TRUE(connection1->NewWindow(child1, ServerWindow::Properties())); |
383 EXPECT_TRUE(connection1->AddWindow(embed_window_id, child1)); | 384 EXPECT_TRUE(connection1->AddWindow(embed_window_id, child1)); |
384 ServerWindow* v1 = connection1->GetWindow(child1); | 385 ServerWindow* v1 = connection1->GetWindow(child1); |
385 v1->SetVisible(true); | 386 v1->SetVisible(true); |
386 v1->SetBounds(gfx::Rect(20, 20, 20, 20)); | 387 v1->SetBounds(gfx::Rect(20, 20, 20, 20)); |
387 | 388 |
388 TestWindowTreeClient* connection1_client = last_window_tree_client(); | 389 TestWindowTreeClient* connection1_client = last_window_tree_client(); |
389 connection1_client->tracker()->changes()->clear(); | 390 connection1_client->tracker()->changes()->clear(); |
390 wm_client()->tracker()->changes()->clear(); | 391 wm_client()->tracker()->changes()->clear(); |
391 | 392 |
392 display_manager_delegate()->OnEvent(CreatePointerDownEvent(21, 22)); | 393 display_manager_delegate()->OnEvent(CreatePointerDownEvent(21, 22)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 EXPECT_EQ(host_connection()->window_tree_host()->root_window(), | 430 EXPECT_EQ(host_connection()->window_tree_host()->root_window(), |
430 host_connection()->window_tree_host()->GetFocusedWindow()); | 431 host_connection()->window_tree_host()->GetFocusedWindow()); |
431 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u); | 432 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u); |
432 EXPECT_EQ("InputEvent window=0,2 event_action=4", | 433 EXPECT_EQ("InputEvent window=0,2 event_action=4", |
433 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 434 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
434 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); | 435 EXPECT_TRUE(connection1_client->tracker()->changes()->empty()); |
435 } | 436 } |
436 | 437 |
437 TEST_F(WindowTreeTest, BasicInputEventTarget) { | 438 TEST_F(WindowTreeTest, BasicInputEventTarget) { |
438 const WindowId embed_window_id(wm_connection()->id(), 1); | 439 const WindowId embed_window_id(wm_connection()->id(), 1); |
439 EXPECT_TRUE(wm_connection()->NewWindow(embed_window_id)); | 440 EXPECT_TRUE( |
| 441 wm_connection()->NewWindow(embed_window_id, ServerWindow::Properties())); |
440 EXPECT_TRUE(wm_connection()->SetWindowVisibility(embed_window_id, true)); | 442 EXPECT_TRUE(wm_connection()->SetWindowVisibility(embed_window_id, true)); |
441 EXPECT_TRUE( | 443 EXPECT_TRUE( |
442 wm_connection()->AddWindow(*(wm_connection()->root()), embed_window_id)); | 444 wm_connection()->AddWindow(*(wm_connection()->root()), embed_window_id)); |
443 host_connection()->window_tree_host()->root_window()->SetBounds( | 445 host_connection()->window_tree_host()->root_window()->SetBounds( |
444 gfx::Rect(0, 0, 100, 100)); | 446 gfx::Rect(0, 0, 100, 100)); |
445 mojom::WindowTreeClientPtr client; | 447 mojom::WindowTreeClientPtr client; |
446 mojo::InterfaceRequest<mojom::WindowTreeClient> client_request = | 448 mojo::InterfaceRequest<mojom::WindowTreeClient> client_request = |
447 GetProxy(&client); | 449 GetProxy(&client); |
448 wm_client()->Bind(client_request.Pass()); | 450 wm_client()->Bind(client_request.Pass()); |
449 ConnectionSpecificId connection_id = 0; | 451 ConnectionSpecificId connection_id = 0; |
450 wm_connection()->Embed(embed_window_id, | 452 wm_connection()->Embed(embed_window_id, |
451 client.Pass(), | 453 client.Pass(), |
452 mojom::WindowTree::ACCESS_POLICY_DEFAULT, | 454 mojom::WindowTree::ACCESS_POLICY_DEFAULT, |
453 &connection_id); | 455 &connection_id); |
454 WindowTreeImpl* connection1 = | 456 WindowTreeImpl* connection1 = |
455 connection_manager()->GetConnectionWithRoot(embed_window_id); | 457 connection_manager()->GetConnectionWithRoot(embed_window_id); |
456 ASSERT_TRUE(connection1 != nullptr); | 458 ASSERT_TRUE(connection1 != nullptr); |
457 ASSERT_NE(connection1, wm_connection()); | 459 ASSERT_NE(connection1, wm_connection()); |
458 | 460 |
459 connection_manager() | 461 connection_manager() |
460 ->GetWindow(embed_window_id) | 462 ->GetWindow(embed_window_id) |
461 ->SetBounds(gfx::Rect(0, 0, 50, 50)); | 463 ->SetBounds(gfx::Rect(0, 0, 50, 50)); |
462 | 464 |
463 const WindowId child1(connection1->id(), 1); | 465 const WindowId child1(connection1->id(), 1); |
464 EXPECT_TRUE(connection1->NewWindow(child1)); | 466 EXPECT_TRUE(connection1->NewWindow(child1, ServerWindow::Properties())); |
465 EXPECT_TRUE(connection1->AddWindow(embed_window_id, child1)); | 467 EXPECT_TRUE(connection1->AddWindow(embed_window_id, child1)); |
466 ServerWindow* v1 = connection1->GetWindow(child1); | 468 ServerWindow* v1 = connection1->GetWindow(child1); |
467 v1->SetVisible(true); | 469 v1->SetVisible(true); |
468 v1->SetBounds(gfx::Rect(20, 20, 20, 20)); | 470 v1->SetBounds(gfx::Rect(20, 20, 20, 20)); |
469 | 471 |
470 TestWindowTreeClient* embed_connection = last_window_tree_client(); | 472 TestWindowTreeClient* embed_connection = last_window_tree_client(); |
471 embed_connection->tracker()->changes()->clear(); | 473 embed_connection->tracker()->changes()->clear(); |
472 wm_client()->tracker()->changes()->clear(); | 474 wm_client()->tracker()->changes()->clear(); |
473 | 475 |
474 // Send an event to |v1|. |embed_connection| should get the event, not | 476 // Send an event to |v1|. |embed_connection| should get the event, not |
475 // |wm_client|, since |v1| lives inside an embedded window. | 477 // |wm_client|, since |v1| lives inside an embedded window. |
476 display_manager_delegate()->OnEvent(CreatePointerDownEvent(21, 22)); | 478 display_manager_delegate()->OnEvent(CreatePointerDownEvent(21, 22)); |
477 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); | 479 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); |
478 EXPECT_EQ("Focused id=2,1", | 480 EXPECT_EQ("Focused id=2,1", |
479 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); | 481 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); |
480 ASSERT_EQ(2u, embed_connection->tracker()->changes()->size()); | 482 ASSERT_EQ(2u, embed_connection->tracker()->changes()->size()); |
481 EXPECT_EQ("Focused id=2,1", | 483 EXPECT_EQ("Focused id=2,1", |
482 ChangesToDescription1(*embed_connection->tracker()->changes())[0]); | 484 ChangesToDescription1(*embed_connection->tracker()->changes())[0]); |
483 EXPECT_EQ("InputEvent window=2,1 event_action=4", | 485 EXPECT_EQ("InputEvent window=2,1 event_action=4", |
484 ChangesToDescription1(*embed_connection->tracker()->changes())[1]); | 486 ChangesToDescription1(*embed_connection->tracker()->changes())[1]); |
485 } | 487 } |
486 | 488 |
487 } // namespace ws | 489 } // namespace ws |
488 | 490 |
489 } // namespace mus | 491 } // namespace mus |
OLD | NEW |