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

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

Issue 331313003: Disables mojo_view_manager_unittests as they are flakey (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge to tot Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 shell::ShellTestHelper test_helper_; 486 shell::ShellTestHelper test_helper_;
487 487
488 ViewManagerInitServicePtr view_manager_init_; 488 ViewManagerInitServicePtr view_manager_init_;
489 489
490 ViewManagerProxy* connection_; 490 ViewManagerProxy* connection_;
491 ViewManagerProxy* connection2_; 491 ViewManagerProxy* connection2_;
492 492
493 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest); 493 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest);
494 }; 494 };
495 495
496 // TODO(sky): reenable tests: http://crbug.com/385475
497
496 // Verifies client gets a valid id. 498 // Verifies client gets a valid id.
497 TEST_F(ViewManagerTest, ValidId) { 499 TEST_F(ViewManagerTest, DISABLED_ValidId) {
498 // TODO(beng): this should really have the URL of the application that 500 // TODO(beng): this should really have the URL of the application that
499 // connected to ViewManagerInit. 501 // connected to ViewManagerInit.
500 EXPECT_EQ("OnConnectionEstablished creator=", 502 EXPECT_EQ("OnConnectionEstablished creator=",
501 ChangesToDescription1(connection_->changes())[0]); 503 ChangesToDescription1(connection_->changes())[0]);
502 504
503 // All these tests assume 1 for the client id. The only real assertion here is 505 // All these tests assume 1 for the client id. The only real assertion here is
504 // the client id is not zero, but adding this as rest of code here assumes 1. 506 // the client id is not zero, but adding this as rest of code here assumes 1.
505 EXPECT_EQ(1, connection_->changes()[0].connection_id); 507 EXPECT_EQ(1, connection_->changes()[0].connection_id);
506 508
507 // Change ids start at 1 as well. 509 // Change ids start at 1 as well.
508 EXPECT_EQ(static_cast<Id>(1), connection_->changes()[0].change_id); 510 EXPECT_EQ(static_cast<Id>(1), connection_->changes()[0].change_id);
509 } 511 }
510 512
511 // Verifies two clients/connections get different ids. 513 // Verifies two clients/connections get different ids.
512 TEST_F(ViewManagerTest, TwoClientsGetDifferentConnectionIds) { 514 TEST_F(ViewManagerTest, DISABLED_TwoClientsGetDifferentConnectionIds) {
513 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 515 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
514 EXPECT_EQ("OnConnectionEstablished creator=mojo:test_url", 516 EXPECT_EQ("OnConnectionEstablished creator=mojo:test_url",
515 ChangesToDescription1(connection2_->changes())[0]); 517 ChangesToDescription1(connection2_->changes())[0]);
516 518
517 // It isn't strickly necessary that the second connection gets 2, but these 519 // It isn't strickly necessary that the second connection gets 2, but these
518 // tests are written assuming that is the case. The key thing is the 520 // tests are written assuming that is the case. The key thing is the
519 // connection ids of |connection_| and |connection2_| differ. 521 // connection ids of |connection_| and |connection2_| differ.
520 EXPECT_EQ(2, connection2_->changes()[0].connection_id); 522 EXPECT_EQ(2, connection2_->changes()[0].connection_id);
521 523
522 // Change ids start at 1 as well. 524 // Change ids start at 1 as well.
523 EXPECT_EQ(static_cast<Id>(1), connection2_->changes()[0].change_id); 525 EXPECT_EQ(static_cast<Id>(1), connection2_->changes()[0].change_id);
524 } 526 }
525 527
526 // Verifies client gets a valid id. 528 // Verifies client gets a valid id.
527 TEST_F(ViewManagerTest, CreateNode) { 529 TEST_F(ViewManagerTest, DISABLED_CreateNode) {
528 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 530 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
529 EXPECT_TRUE(connection_->changes().empty()); 531 EXPECT_TRUE(connection_->changes().empty());
530 532
531 // Can't create a node with the same id. 533 // Can't create a node with the same id.
532 ASSERT_FALSE(connection_->CreateNode(BuildNodeId(1, 1))); 534 ASSERT_FALSE(connection_->CreateNode(BuildNodeId(1, 1)));
533 EXPECT_TRUE(connection_->changes().empty()); 535 EXPECT_TRUE(connection_->changes().empty());
534 536
535 // Can't create a node with a bogus connection id. 537 // Can't create a node with a bogus connection id.
536 EXPECT_FALSE(connection_->CreateNode(BuildNodeId(2, 1))); 538 EXPECT_FALSE(connection_->CreateNode(BuildNodeId(2, 1)));
537 EXPECT_TRUE(connection_->changes().empty()); 539 EXPECT_TRUE(connection_->changes().empty());
538 } 540 }
539 541
540 TEST_F(ViewManagerTest, CreateViewFailsWithBogusConnectionId) { 542 TEST_F(ViewManagerTest, DISABLED_CreateViewFailsWithBogusConnectionId) {
541 EXPECT_FALSE(connection_->CreateView(BuildViewId(2, 1))); 543 EXPECT_FALSE(connection_->CreateView(BuildViewId(2, 1)));
542 EXPECT_TRUE(connection_->changes().empty()); 544 EXPECT_TRUE(connection_->changes().empty());
543 } 545 }
544 546
545 // Verifies hierarchy changes. 547 // Verifies hierarchy changes.
546 TEST_F(ViewManagerTest, AddRemoveNotify) { 548 TEST_F(ViewManagerTest, DISABLED_AddRemoveNotify) {
547 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 549 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
548 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); 550 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3)));
549 551
550 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 552 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
551 553
552 // Make 3 a child of 2. 554 // Make 3 a child of 2.
553 { 555 {
554 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 3), 1)); 556 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 3), 1));
555 EXPECT_TRUE(connection_->changes().empty()); 557 EXPECT_TRUE(connection_->changes().empty());
556 558
557 connection2_->DoRunLoopUntilChangesCount(1); 559 connection2_->DoRunLoopUntilChangesCount(1);
558 const Changes changes(ChangesToDescription1(connection2_->changes())); 560 const Changes changes(ChangesToDescription1(connection2_->changes()));
559 ASSERT_EQ(1u, changes.size()); 561 ASSERT_EQ(1u, changes.size());
560 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 562 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
561 } 563 }
562 564
563 // Remove 3 from its parent. 565 // Remove 3 from its parent.
564 { 566 {
565 ASSERT_TRUE(connection_->RemoveNodeFromParent(BuildNodeId(1, 3), 2)); 567 ASSERT_TRUE(connection_->RemoveNodeFromParent(BuildNodeId(1, 3), 2));
566 EXPECT_TRUE(connection_->changes().empty()); 568 EXPECT_TRUE(connection_->changes().empty());
567 569
568 connection2_->DoRunLoopUntilChangesCount(1); 570 connection2_->DoRunLoopUntilChangesCount(1);
569 const Changes changes(ChangesToDescription1(connection2_->changes())); 571 const Changes changes(ChangesToDescription1(connection2_->changes()));
570 ASSERT_EQ(1u, changes.size()); 572 ASSERT_EQ(1u, changes.size());
571 EXPECT_EQ("ServerChangeIdAdvanced 3", changes[0]); 573 EXPECT_EQ("ServerChangeIdAdvanced 3", changes[0]);
572 } 574 }
573 } 575 }
574 576
575 // Verifies AddNode fails when node is already in position. 577 // Verifies AddNode fails when node is already in position.
576 TEST_F(ViewManagerTest, AddNodeWithNoChange) { 578 TEST_F(ViewManagerTest, DISABLED_AddNodeWithNoChange) {
577 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 579 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
578 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); 580 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3)));
579 581
580 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 582 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
581 583
582 // Make 3 a child of 2. 584 // Make 3 a child of 2.
583 { 585 {
584 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 3), 1)); 586 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 3), 1));
585 587
586 connection2_->DoRunLoopUntilChangesCount(1); 588 connection2_->DoRunLoopUntilChangesCount(1);
587 const Changes changes(ChangesToDescription1(connection2_->changes())); 589 const Changes changes(ChangesToDescription1(connection2_->changes()));
588 ASSERT_EQ(1u, changes.size()); 590 ASSERT_EQ(1u, changes.size());
589 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 591 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
590 } 592 }
591 593
592 // Try again, this should fail. 594 // Try again, this should fail.
593 { 595 {
594 EXPECT_FALSE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 3), 2)); 596 EXPECT_FALSE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 3), 2));
595 } 597 }
596 } 598 }
597 599
598 // Verifies AddNode fails when node is already in position. 600 // Verifies AddNode fails when node is already in position.
599 TEST_F(ViewManagerTest, AddAncestorFails) { 601 TEST_F(ViewManagerTest, DISABLED_AddAncestorFails) {
600 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 602 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
601 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); 603 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3)));
602 604
603 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 605 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
604 606
605 // Make 3 a child of 2. 607 // Make 3 a child of 2.
606 { 608 {
607 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 3), 1)); 609 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 3), 1));
608 connection2_->DoRunLoopUntilChangesCount(1); 610 connection2_->DoRunLoopUntilChangesCount(1);
609 const Changes changes(ChangesToDescription1(connection2_->changes())); 611 const Changes changes(ChangesToDescription1(connection2_->changes()));
610 ASSERT_EQ(1u, changes.size()); 612 ASSERT_EQ(1u, changes.size());
611 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 613 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
612 } 614 }
613 615
614 // Try to make 2 a child of 3, this should fail since 2 is an ancestor of 3. 616 // Try to make 2 a child of 3, this should fail since 2 is an ancestor of 3.
615 { 617 {
616 EXPECT_FALSE(connection_->AddNode(BuildNodeId(1, 3), BuildNodeId(1, 2), 2)); 618 EXPECT_FALSE(connection_->AddNode(BuildNodeId(1, 3), BuildNodeId(1, 2), 2));
617 } 619 }
618 } 620 }
619 621
620 // Verifies adding with an invalid id fails. 622 // Verifies adding with an invalid id fails.
621 TEST_F(ViewManagerTest, AddWithInvalidServerId) { 623 TEST_F(ViewManagerTest, DISABLED_AddWithInvalidServerId) {
622 // Create two nodes. 624 // Create two nodes.
623 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 625 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
624 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 626 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
625 627
626 // Make 2 a child of 1. Supply an invalid change id, which should fail. 628 // Make 2 a child of 1. Supply an invalid change id, which should fail.
627 ASSERT_FALSE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 0)); 629 ASSERT_FALSE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 0));
628 } 630 }
629 631
630 // Verifies adding to root sends right notifications. 632 // Verifies adding to root sends right notifications.
631 TEST_F(ViewManagerTest, AddToRoot) { 633 TEST_F(ViewManagerTest, DISABLED_AddToRoot) {
632 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 21))); 634 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 21)));
633 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); 635 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3)));
634 636
635 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 637 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
636 638
637 // Make 3 a child of 21. 639 // Make 3 a child of 21.
638 { 640 {
639 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 21), BuildNodeId(1, 3), 1)); 641 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 21), BuildNodeId(1, 3), 1));
640 642
641 connection2_->DoRunLoopUntilChangesCount(1); 643 connection2_->DoRunLoopUntilChangesCount(1);
642 const Changes changes(ChangesToDescription1(connection2_->changes())); 644 const Changes changes(ChangesToDescription1(connection2_->changes()));
643 ASSERT_EQ(1u, changes.size()); 645 ASSERT_EQ(1u, changes.size());
644 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 646 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
645 } 647 }
646 648
647 // Make 21 a child of 1. 649 // Make 21 a child of 1.
648 { 650 {
649 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 21), 2)); 651 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 21), 2));
650 652
651 connection2_->DoRunLoopUntilChangesCount(1); 653 connection2_->DoRunLoopUntilChangesCount(1);
652 const Changes changes(ChangesToDescription1(connection2_->changes())); 654 const Changes changes(ChangesToDescription1(connection2_->changes()));
653 ASSERT_EQ(1u, changes.size()); 655 ASSERT_EQ(1u, changes.size());
654 EXPECT_EQ( 656 EXPECT_EQ(
655 "HierarchyChanged change_id=2 node=1,21 new_parent=1,1 old_parent=null", 657 "HierarchyChanged change_id=2 node=1,21 new_parent=1,1 old_parent=null",
656 changes[0]); 658 changes[0]);
657 } 659 }
658 } 660 }
659 661
660 // Verifies HierarchyChanged is correctly sent for various adds/removes. 662 // Verifies HierarchyChanged is correctly sent for various adds/removes.
661 TEST_F(ViewManagerTest, NodeHierarchyChangedNodes) { 663 TEST_F(ViewManagerTest, DISABLED_NodeHierarchyChangedNodes) {
662 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 664 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
663 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 11))); 665 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 11)));
664 // Make 11 a child of 2. 666 // Make 11 a child of 2.
665 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 11), 1)); 667 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 2), BuildNodeId(1, 11), 1));
666 668
667 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 669 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
668 670
669 // Make 2 a child of 1. 671 // Make 2 a child of 1.
670 { 672 {
671 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 2)); 673 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 2));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 connection2_->DoRunLoopUntilChangesCount(1); 736 connection2_->DoRunLoopUntilChangesCount(1);
735 const Changes changes(ChangesToDescription1(connection2_->changes())); 737 const Changes changes(ChangesToDescription1(connection2_->changes()));
736 ASSERT_EQ(1u, changes.size()); 738 ASSERT_EQ(1u, changes.size());
737 EXPECT_EQ( 739 EXPECT_EQ(
738 "HierarchyChanged change_id=6 node=1,1 new_parent=null old_parent=null", 740 "HierarchyChanged change_id=6 node=1,1 new_parent=null old_parent=null",
739 changes[0]); 741 changes[0]);
740 EXPECT_EQ(std::string(), ChangeNodeDescription(connection2_->changes())); 742 EXPECT_EQ(std::string(), ChangeNodeDescription(connection2_->changes()));
741 } 743 }
742 } 744 }
743 745
744 TEST_F(ViewManagerTest, NodeHierarchyChangedAddingKnownToUnknown) { 746 TEST_F(ViewManagerTest, DISABLED_NodeHierarchyChangedAddingKnownToUnknown) {
745 // Create the following structure: root -> 1 -> 11 and 2->21 (2 has no 747 // Create the following structure: root -> 1 -> 11 and 2->21 (2 has no
746 // parent). 748 // parent).
747 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 749 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
748 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 11))); 750 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 11)));
749 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 751 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
750 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 21))); 752 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 21)));
751 753
752 // Set up the hierarchy. 754 // Set up the hierarchy.
753 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); 755 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1));
754 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 11), 2)); 756 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 11), 2));
(...skipping 26 matching lines...) Expand all
781 ASSERT_EQ(1u, changes.size()); 783 ASSERT_EQ(1u, changes.size());
782 EXPECT_EQ( 784 EXPECT_EQ(
783 "HierarchyChanged change_id=5 node=1,2 new_parent=1,1 old_parent=null", 785 "HierarchyChanged change_id=5 node=1,2 new_parent=1,1 old_parent=null",
784 changes[0]); 786 changes[0]);
785 EXPECT_EQ("[node=1,2 parent=1,1 view=null]," 787 EXPECT_EQ("[node=1,2 parent=1,1 view=null],"
786 "[node=1,21 parent=1,2 view=null]", 788 "[node=1,21 parent=1,2 view=null]",
787 ChangeNodeDescription(connection2_->changes())); 789 ChangeNodeDescription(connection2_->changes()));
788 } 790 }
789 } 791 }
790 792
791 TEST_F(ViewManagerTest, ReorderNode) { 793 TEST_F(ViewManagerTest, DISABLED_ReorderNode) {
792 Id node1_id = BuildNodeId(1, 1); 794 Id node1_id = BuildNodeId(1, 1);
793 Id node2_id = BuildNodeId(1, 2); 795 Id node2_id = BuildNodeId(1, 2);
794 Id node3_id = BuildNodeId(1, 3); 796 Id node3_id = BuildNodeId(1, 3);
795 Id node4_id = BuildNodeId(1, 4); // Peer to 1,1 797 Id node4_id = BuildNodeId(1, 4); // Peer to 1,1
796 Id node5_id = BuildNodeId(1, 5); // Peer to 1,1 798 Id node5_id = BuildNodeId(1, 5); // Peer to 1,1
797 Id node6_id = BuildNodeId(1, 6); // Child of 1,2. 799 Id node6_id = BuildNodeId(1, 6); // Child of 1,2.
798 Id node7_id = BuildNodeId(1, 7); // Unparented. 800 Id node7_id = BuildNodeId(1, 7); // Unparented.
799 Id node8_id = BuildNodeId(1, 8); // Unparented. 801 Id node8_id = BuildNodeId(1, 8); // Unparented.
800 ASSERT_TRUE(connection_->CreateNode(node1_id)); 802 ASSERT_TRUE(connection_->CreateNode(node1_id));
801 ASSERT_TRUE(connection_->CreateNode(node2_id)); 803 ASSERT_TRUE(connection_->CreateNode(node2_id));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 8)); 862 8));
861 } 863 }
862 864
863 { 865 {
864 // node7 & node8 are un-parented. 866 // node7 & node8 are un-parented.
865 EXPECT_FALSE(connection_->ReorderNode(node7_id, node8_id, ORDER_ABOVE, 8)); 867 EXPECT_FALSE(connection_->ReorderNode(node7_id, node8_id, ORDER_ABOVE, 8));
866 } 868 }
867 } 869 }
868 870
869 // Verifies DeleteNode works. 871 // Verifies DeleteNode works.
870 TEST_F(ViewManagerTest, DeleteNode) { 872 TEST_F(ViewManagerTest, DISABLED_DeleteNode) {
871 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 873 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
872 874
873 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 875 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
874 876
875 // Make 2 a child of 1. 877 // Make 2 a child of 1.
876 { 878 {
877 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1)); 879 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1));
878 connection2_->DoRunLoopUntilChangesCount(1); 880 connection2_->DoRunLoopUntilChangesCount(1);
879 const Changes changes(ChangesToDescription1(connection2_->changes())); 881 const Changes changes(ChangesToDescription1(connection2_->changes()));
880 ASSERT_EQ(1u, changes.size()); 882 ASSERT_EQ(1u, changes.size());
881 EXPECT_EQ("HierarchyChanged change_id=1 node=1,2 new_parent=1,1 " 883 EXPECT_EQ("HierarchyChanged change_id=1 node=1,2 new_parent=1,1 "
882 "old_parent=null", changes[0]); 884 "old_parent=null", changes[0]);
883 } 885 }
884 886
885 // Delete 2. 887 // Delete 2.
886 { 888 {
887 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 2), 2)); 889 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 2), 2));
888 EXPECT_TRUE(connection_->changes().empty()); 890 EXPECT_TRUE(connection_->changes().empty());
889 891
890 connection2_->DoRunLoopUntilChangesCount(1); 892 connection2_->DoRunLoopUntilChangesCount(1);
891 const Changes changes(ChangesToDescription1(connection2_->changes())); 893 const Changes changes(ChangesToDescription1(connection2_->changes()));
892 ASSERT_EQ(1u, changes.size()); 894 ASSERT_EQ(1u, changes.size());
893 EXPECT_EQ("NodeDeleted change_id=2 node=1,2", changes[0]); 895 EXPECT_EQ("NodeDeleted change_id=2 node=1,2", changes[0]);
894 } 896 }
895 } 897 }
896 898
897 // Verifies DeleteNode isn't allowed from a separate connection. 899 // Verifies DeleteNode isn't allowed from a separate connection.
898 TEST_F(ViewManagerTest, DeleteNodeFromAnotherConnectionDisallowed) { 900 TEST_F(ViewManagerTest, DISABLED_DeleteNodeFromAnotherConnectionDisallowed) {
899 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 901 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
900 EXPECT_FALSE(connection2_->DeleteNode(BuildNodeId(1, 1), 1)); 902 EXPECT_FALSE(connection2_->DeleteNode(BuildNodeId(1, 1), 1));
901 } 903 }
902 904
903 // Verifies DeleteView isn't allowed from a separate connection. 905 // Verifies DeleteView isn't allowed from a separate connection.
904 TEST_F(ViewManagerTest, DeleteViewFromAnotherConnectionDisallowed) { 906 TEST_F(ViewManagerTest, DISABLED_DeleteViewFromAnotherConnectionDisallowed) {
905 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 1))); 907 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 1)));
906 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 908 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
907 EXPECT_FALSE(connection2_->DeleteView(BuildViewId(1, 1))); 909 EXPECT_FALSE(connection2_->DeleteView(BuildViewId(1, 1)));
908 } 910 }
909 911
910 // Verifies if a node was deleted and then reused that other clients are 912 // Verifies if a node was deleted and then reused that other clients are
911 // properly notified. 913 // properly notified.
912 TEST_F(ViewManagerTest, ReuseDeletedNodeId) { 914 TEST_F(ViewManagerTest, DISABLED_ReuseDeletedNodeId) {
913 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 915 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
914 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 916 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
915 917
916 // Add 2 to 1. 918 // Add 2 to 1.
917 { 919 {
918 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1)); 920 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1));
919 921
920 connection2_->DoRunLoopUntilChangesCount(1); 922 connection2_->DoRunLoopUntilChangesCount(1);
921 const Changes changes(ChangesToDescription1(connection2_->changes())); 923 const Changes changes(ChangesToDescription1(connection2_->changes()));
922 EXPECT_EQ( 924 EXPECT_EQ(
(...skipping 22 matching lines...) Expand all
945 const Changes changes(ChangesToDescription1(connection2_->changes())); 947 const Changes changes(ChangesToDescription1(connection2_->changes()));
946 EXPECT_EQ( 948 EXPECT_EQ(
947 "HierarchyChanged change_id=3 node=1,2 new_parent=1,1 old_parent=null", 949 "HierarchyChanged change_id=3 node=1,2 new_parent=1,1 old_parent=null",
948 changes[0]); 950 changes[0]);
949 EXPECT_EQ("[node=1,2 parent=1,1 view=null]", 951 EXPECT_EQ("[node=1,2 parent=1,1 view=null]",
950 ChangeNodeDescription(connection2_->changes())); 952 ChangeNodeDescription(connection2_->changes()));
951 } 953 }
952 } 954 }
953 955
954 // Assertions around setting a view. 956 // Assertions around setting a view.
955 TEST_F(ViewManagerTest, SetView) { 957 TEST_F(ViewManagerTest, DISABLED_SetView) {
956 // Create nodes 1, 2 and 3 and the view 11. Nodes 2 and 3 are parented to 1. 958 // Create nodes 1, 2 and 3 and the view 11. Nodes 2 and 3 are parented to 1.
957 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 959 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
958 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 960 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
959 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); 961 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3)));
960 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 11))); 962 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 11)));
961 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1)); 963 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1));
962 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 3), 2)); 964 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 3), 2));
963 965
964 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 966 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
965 967
(...skipping 17 matching lines...) Expand all
983 const Changes changes(ChangesToDescription1(connection2_->changes())); 985 const Changes changes(ChangesToDescription1(connection2_->changes()));
984 ASSERT_EQ(2u, changes.size()); 986 ASSERT_EQ(2u, changes.size());
985 EXPECT_EQ("ViewReplaced node=1,1 new_view=null old_view=1,11", 987 EXPECT_EQ("ViewReplaced node=1,1 new_view=null old_view=1,11",
986 changes[0]); 988 changes[0]);
987 EXPECT_EQ("ViewReplaced node=1,2 new_view=1,11 old_view=null", 989 EXPECT_EQ("ViewReplaced node=1,2 new_view=1,11 old_view=null",
988 changes[1]); 990 changes[1]);
989 } 991 }
990 } 992 }
991 993
992 // Verifies deleting a node with a view sends correct notifications. 994 // Verifies deleting a node with a view sends correct notifications.
993 TEST_F(ViewManagerTest, DeleteNodeWithView) { 995 TEST_F(ViewManagerTest, DISABLED_DeleteNodeWithView) {
994 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 996 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
995 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 997 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
996 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); 998 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3)));
997 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 11))); 999 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 11)));
998 1000
999 // Set view 11 on node 2. 1001 // Set view 11 on node 2.
1000 ASSERT_TRUE(connection_->SetView(BuildNodeId(1, 2), BuildViewId(1, 11))); 1002 ASSERT_TRUE(connection_->SetView(BuildNodeId(1, 2), BuildViewId(1, 11)));
1001 1003
1002 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1004 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1003 1005
(...skipping 27 matching lines...) Expand all
1031 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 3), 3)); 1033 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 3), 3));
1032 1034
1033 connection2_->DoRunLoopUntilChangesCount(1); 1035 connection2_->DoRunLoopUntilChangesCount(1);
1034 const Changes changes(ChangesToDescription1(connection2_->changes())); 1036 const Changes changes(ChangesToDescription1(connection2_->changes()));
1035 ASSERT_EQ(1u, changes.size()); 1037 ASSERT_EQ(1u, changes.size());
1036 EXPECT_EQ("NodeDeleted change_id=3 node=1,3", changes[0]); 1038 EXPECT_EQ("NodeDeleted change_id=3 node=1,3", changes[0]);
1037 } 1039 }
1038 } 1040 }
1039 1041
1040 // Sets view from one connection on another. 1042 // Sets view from one connection on another.
1041 TEST_F(ViewManagerTest, SetViewFromSecondConnection) { 1043 TEST_F(ViewManagerTest, DISABLED_SetViewFromSecondConnection) {
1042 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1044 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1043 1045
1044 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1046 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1045 1047
1046 // Create a view in the second connection. 1048 // Create a view in the second connection.
1047 ASSERT_TRUE(connection2_->CreateView(BuildViewId(2, 51))); 1049 ASSERT_TRUE(connection2_->CreateView(BuildViewId(2, 51)));
1048 1050
1049 // Attach view to node 1 in the first connection. 1051 // Attach view to node 1 in the first connection.
1050 { 1052 {
1051 ASSERT_TRUE(connection2_->SetView(BuildNodeId(1, 1), BuildViewId(2, 51))); 1053 ASSERT_TRUE(connection2_->SetView(BuildNodeId(1, 1), BuildViewId(2, 51)));
1052 connection_->DoRunLoopUntilChangesCount(1); 1054 connection_->DoRunLoopUntilChangesCount(1);
1053 const Changes changes(ChangesToDescription1(connection_->changes())); 1055 const Changes changes(ChangesToDescription1(connection_->changes()));
1054 ASSERT_EQ(1u, changes.size()); 1056 ASSERT_EQ(1u, changes.size());
1055 EXPECT_EQ("ViewReplaced node=1,1 new_view=2,51 old_view=null", changes[0]); 1057 EXPECT_EQ("ViewReplaced node=1,1 new_view=2,51 old_view=null", changes[0]);
1056 } 1058 }
1057 1059
1058 // Shutdown the second connection and verify view is removed. 1060 // Shutdown the second connection and verify view is removed.
1059 { 1061 {
1060 DestroySecondConnection(); 1062 DestroySecondConnection();
1061 connection_->DoRunLoopUntilChangesCount(2); 1063 connection_->DoRunLoopUntilChangesCount(2);
1062 const Changes changes(ChangesToDescription1(connection_->changes())); 1064 const Changes changes(ChangesToDescription1(connection_->changes()));
1063 ASSERT_EQ(2u, changes.size()); 1065 ASSERT_EQ(2u, changes.size());
1064 EXPECT_EQ("ViewReplaced node=1,1 new_view=null old_view=2,51", changes[0]); 1066 EXPECT_EQ("ViewReplaced node=1,1 new_view=null old_view=2,51", changes[0]);
1065 EXPECT_EQ("ViewDeleted view=2,51", changes[1]); 1067 EXPECT_EQ("ViewDeleted view=2,51", changes[1]);
1066 } 1068 }
1067 } 1069 }
1068 1070
1069 // Assertions for GetNodeTree. 1071 // Assertions for GetNodeTree.
1070 TEST_F(ViewManagerTest, GetNodeTree) { 1072 TEST_F(ViewManagerTest, DISABLED_GetNodeTree) {
1071 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1073 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1072 1074
1073 // Create 11 in first connection and make it a child of 1. 1075 // Create 11 in first connection and make it a child of 1.
1074 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 11))); 1076 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 11)));
1075 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); 1077 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1));
1076 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 11), 2)); 1078 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 11), 2));
1077 1079
1078 // Create two nodes in second connection, 2 and 3, both children of 1. 1080 // Create two nodes in second connection, 2 and 3, both children of 1.
1079 ASSERT_TRUE(connection2_->CreateNode(BuildNodeId(2, 2))); 1081 ASSERT_TRUE(connection2_->CreateNode(BuildNodeId(2, 2)));
1080 ASSERT_TRUE(connection2_->CreateNode(BuildNodeId(2, 3))); 1082 ASSERT_TRUE(connection2_->CreateNode(BuildNodeId(2, 3)));
(...skipping 28 matching lines...) Expand all
1109 } 1111 }
1110 1112
1111 // Connection 2 shouldn't be able to get the root tree. 1113 // Connection 2 shouldn't be able to get the root tree.
1112 { 1114 {
1113 std::vector<TestNode> nodes; 1115 std::vector<TestNode> nodes;
1114 connection2_->GetNodeTree(BuildNodeId(0, 1), &nodes); 1116 connection2_->GetNodeTree(BuildNodeId(0, 1), &nodes);
1115 ASSERT_EQ(0u, nodes.size()); 1117 ASSERT_EQ(0u, nodes.size());
1116 } 1118 }
1117 } 1119 }
1118 1120
1119 TEST_F(ViewManagerTest, SetNodeBounds) { 1121 TEST_F(ViewManagerTest, DISABLED_SetNodeBounds) {
1120 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1122 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1121 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); 1123 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1));
1122 1124
1123 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1125 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1124 1126
1125 ASSERT_TRUE(connection_->SetNodeBounds(BuildNodeId(1, 1), 1127 ASSERT_TRUE(connection_->SetNodeBounds(BuildNodeId(1, 1),
1126 gfx::Rect(0, 0, 100, 100))); 1128 gfx::Rect(0, 0, 100, 100)));
1127 1129
1128 connection2_->DoRunLoopUntilChangesCount(1); 1130 connection2_->DoRunLoopUntilChangesCount(1);
1129 const Changes changes(ChangesToDescription1(connection2_->changes())); 1131 const Changes changes(ChangesToDescription1(connection2_->changes()));
1130 ASSERT_EQ(1u, changes.size()); 1132 ASSERT_EQ(1u, changes.size());
1131 EXPECT_EQ("BoundsChanged node=1,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100", 1133 EXPECT_EQ("BoundsChanged node=1,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100",
1132 changes[0]); 1134 changes[0]);
1133 1135
1134 // Should not be possible to change the bounds of a node created by another 1136 // Should not be possible to change the bounds of a node created by another
1135 // connection. 1137 // connection.
1136 ASSERT_FALSE(connection2_->SetNodeBounds(BuildNodeId(1, 1), 1138 ASSERT_FALSE(connection2_->SetNodeBounds(BuildNodeId(1, 1),
1137 gfx::Rect(0, 0, 0, 0))); 1139 gfx::Rect(0, 0, 0, 0)));
1138 } 1140 }
1139 1141
1140 // Various assertions around SetRoots. 1142 // Various assertions around SetRoots.
1141 TEST_F(ViewManagerTest, SetRoots) { 1143 TEST_F(ViewManagerTest, DISABLED_SetRoots) {
1142 // Create 1, 2, and 3 in the first connection. 1144 // Create 1, 2, and 3 in the first connection.
1143 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1145 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1144 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1146 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1145 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); 1147 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3)));
1146 1148
1147 // Parent 1 to the root. 1149 // Parent 1 to the root.
1148 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); 1150 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1));
1149 1151
1150 // Establish the second connection and give it the roots 1 and 3. 1152 // Establish the second connection and give it the roots 1 and 3.
1151 { 1153 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 4), 5)); 1200 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 4), 5));
1199 1201
1200 connection2_->DoRunLoopUntilChangesCount(1); 1202 connection2_->DoRunLoopUntilChangesCount(1);
1201 const Changes changes(ChangesToDescription1(connection2_->changes())); 1203 const Changes changes(ChangesToDescription1(connection2_->changes()));
1202 ASSERT_EQ(1u, changes.size()); 1204 ASSERT_EQ(1u, changes.size());
1203 EXPECT_EQ("ServerChangeIdAdvanced 6", changes[0]); 1205 EXPECT_EQ("ServerChangeIdAdvanced 6", changes[0]);
1204 } 1206 }
1205 } 1207 }
1206 1208
1207 // Verify AddNode fails when trying to manipulate nodes in other roots. 1209 // Verify AddNode fails when trying to manipulate nodes in other roots.
1208 TEST_F(ViewManagerTest, CantMoveNodesFromOtherRoot) { 1210 TEST_F(ViewManagerTest, DISABLED_CantMoveNodesFromOtherRoot) {
1209 // Create 1 and 2 in the first connection. 1211 // Create 1 and 2 in the first connection.
1210 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1212 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1211 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1213 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1212 1214
1213 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1215 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1214 1216
1215 // Try to move 2 to be a child of 1 from connection 2. This should fail as 2 1217 // Try to move 2 to be a child of 1 from connection 2. This should fail as 2
1216 // should not be able to access 1. 1218 // should not be able to access 1.
1217 ASSERT_FALSE(connection2_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1)); 1219 ASSERT_FALSE(connection2_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1));
1218 1220
1219 // Try to reparent 1 to the root. A connection is not allowed to reparent its 1221 // Try to reparent 1 to the root. A connection is not allowed to reparent its
1220 // roots. 1222 // roots.
1221 ASSERT_FALSE(connection2_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); 1223 ASSERT_FALSE(connection2_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1));
1222 } 1224 }
1223 1225
1224 // Verify RemoveNodeFromParent fails for nodes that are descendants of the 1226 // Verify RemoveNodeFromParent fails for nodes that are descendants of the
1225 // roots. 1227 // roots.
1226 TEST_F(ViewManagerTest, CantRemoveNodesInOtherRoots) { 1228 TEST_F(ViewManagerTest, DISABLED_CantRemoveNodesInOtherRoots) {
1227 // Create 1 and 2 in the first connection and parent both to the root. 1229 // Create 1 and 2 in the first connection and parent both to the root.
1228 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1230 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1229 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1231 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1230 1232
1231 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); 1233 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1));
1232 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 2), 2)); 1234 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 2), 2));
1233 1235
1234 // Establish the second connection and give it the root 1. 1236 // Establish the second connection and give it the root 1.
1235 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1237 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1236 1238
(...skipping 15 matching lines...) Expand all
1252 std::vector<TestNode> nodes; 1254 std::vector<TestNode> nodes;
1253 connection_->GetNodeTree(BuildNodeId(0, 1), &nodes); 1255 connection_->GetNodeTree(BuildNodeId(0, 1), &nodes);
1254 ASSERT_EQ(3u, nodes.size()); 1256 ASSERT_EQ(3u, nodes.size());
1255 EXPECT_EQ("node=0,1 parent=null view=null", nodes[0].ToString()); 1257 EXPECT_EQ("node=0,1 parent=null view=null", nodes[0].ToString());
1256 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[1].ToString()); 1258 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[1].ToString());
1257 EXPECT_EQ("node=1,2 parent=0,1 view=null", nodes[2].ToString()); 1259 EXPECT_EQ("node=1,2 parent=0,1 view=null", nodes[2].ToString());
1258 } 1260 }
1259 } 1261 }
1260 1262
1261 // Verify SetView fails for nodes that are not descendants of the roots. 1263 // Verify SetView fails for nodes that are not descendants of the roots.
1262 TEST_F(ViewManagerTest, CantRemoveSetViewInOtherRoots) { 1264 TEST_F(ViewManagerTest, DISABLED_CantRemoveSetViewInOtherRoots) {
1263 // Create 1 and 2 in the first connection and parent both to the root. 1265 // Create 1 and 2 in the first connection and parent both to the root.
1264 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1266 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1265 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1267 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1266 1268
1267 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); 1269 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1));
1268 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 2), 2)); 1270 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 2), 2));
1269 1271
1270 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1272 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1271 1273
1272 // Create a view in the second connection. 1274 // Create a view in the second connection.
1273 ASSERT_TRUE(connection2_->CreateView(BuildViewId(2, 51))); 1275 ASSERT_TRUE(connection2_->CreateView(BuildViewId(2, 51)));
1274 1276
1275 // Connection 2 should be able to set the view on node 1 (it's root), but not 1277 // Connection 2 should be able to set the view on node 1 (it's root), but not
1276 // on 2. 1278 // on 2.
1277 ASSERT_TRUE(connection2_->SetView(BuildNodeId(1, 1), BuildViewId(2, 51))); 1279 ASSERT_TRUE(connection2_->SetView(BuildNodeId(1, 1), BuildViewId(2, 51)));
1278 ASSERT_FALSE(connection2_->SetView(BuildNodeId(1, 2), BuildViewId(2, 51))); 1280 ASSERT_FALSE(connection2_->SetView(BuildNodeId(1, 2), BuildViewId(2, 51)));
1279 } 1281 }
1280 1282
1281 // Verify GetNodeTree fails for nodes that are not descendants of the roots. 1283 // Verify GetNodeTree fails for nodes that are not descendants of the roots.
1282 TEST_F(ViewManagerTest, CantGetNodeTreeOfOtherRoots) { 1284 TEST_F(ViewManagerTest, DISABLED_CantGetNodeTreeOfOtherRoots) {
1283 // Create 1 and 2 in the first connection and parent both to the root. 1285 // Create 1 and 2 in the first connection and parent both to the root.
1284 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1286 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1285 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1287 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1286 1288
1287 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); 1289 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1));
1288 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 2), 2)); 1290 ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 2), 2));
1289 1291
1290 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1292 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1291 1293
1292 std::vector<TestNode> nodes; 1294 std::vector<TestNode> nodes;
1293 1295
1294 // Should get nothing for the root. 1296 // Should get nothing for the root.
1295 connection2_->GetNodeTree(BuildNodeId(0, 1), &nodes); 1297 connection2_->GetNodeTree(BuildNodeId(0, 1), &nodes);
1296 ASSERT_TRUE(nodes.empty()); 1298 ASSERT_TRUE(nodes.empty());
1297 1299
1298 // Should get nothing for node 2. 1300 // Should get nothing for node 2.
1299 connection2_->GetNodeTree(BuildNodeId(1, 2), &nodes); 1301 connection2_->GetNodeTree(BuildNodeId(1, 2), &nodes);
1300 ASSERT_TRUE(nodes.empty()); 1302 ASSERT_TRUE(nodes.empty());
1301 1303
1302 // Should get node 1 if asked for. 1304 // Should get node 1 if asked for.
1303 connection2_->GetNodeTree(BuildNodeId(1, 1), &nodes); 1305 connection2_->GetNodeTree(BuildNodeId(1, 1), &nodes);
1304 ASSERT_EQ(1u, nodes.size()); 1306 ASSERT_EQ(1u, nodes.size());
1305 EXPECT_EQ("node=1,1 parent=null view=null", nodes[0].ToString()); 1307 EXPECT_EQ("node=1,1 parent=null view=null", nodes[0].ToString());
1306 } 1308 }
1307 1309
1308 TEST_F(ViewManagerTest, ConnectTwice) { 1310 TEST_F(ViewManagerTest, DISABLED_ConnectTwice) {
1309 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1311 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1310 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1312 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1311 1313
1312 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1)); 1314 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1));
1313 1315
1314 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1316 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1315 1317
1316 // Try to connect again to 1,1, this should fail as already connected to that 1318 // Try to connect again to 1,1, this should fail as already connected to that
1317 // root. 1319 // root.
1318 { 1320 {
1319 std::vector<Id> node_ids; 1321 std::vector<Id> node_ids;
1320 node_ids.push_back(BuildNodeId(1, 1)); 1322 node_ids.push_back(BuildNodeId(1, 1));
1321 ASSERT_FALSE(connection_->Embed(node_ids)); 1323 ASSERT_FALSE(connection_->Embed(node_ids));
1322 } 1324 }
1323 1325
1324 // Connecting to 1,2 should succeed and end up in connection2. 1326 // Connecting to 1,2 should succeed and end up in connection2.
1325 { 1327 {
1326 std::vector<Id> node_ids; 1328 std::vector<Id> node_ids;
1327 node_ids.push_back(BuildNodeId(1, 2)); 1329 node_ids.push_back(BuildNodeId(1, 2));
1328 ASSERT_TRUE(connection_->Embed(node_ids)); 1330 ASSERT_TRUE(connection_->Embed(node_ids));
1329 connection2_->DoRunLoopUntilChangesCount(1); 1331 connection2_->DoRunLoopUntilChangesCount(1);
1330 const Changes changes(ChangesToDescription1(connection2_->changes())); 1332 const Changes changes(ChangesToDescription1(connection2_->changes()));
1331 ASSERT_EQ(1u, changes.size()); 1333 ASSERT_EQ(1u, changes.size());
1332 EXPECT_EQ("OnRootsAdded", changes[0]); 1334 EXPECT_EQ("OnRootsAdded", changes[0]);
1333 EXPECT_EQ("[node=1,2 parent=1,1 view=null]", 1335 EXPECT_EQ("[node=1,2 parent=1,1 view=null]",
1334 ChangeNodeDescription(connection2_->changes())); 1336 ChangeNodeDescription(connection2_->changes()));
1335 } 1337 }
1336 } 1338 }
1337 1339
1338 TEST_F(ViewManagerTest, OnViewInput) { 1340 TEST_F(ViewManagerTest, DISABLED_OnViewInput) {
1339 // Create node 1 and assign a view from connection 2 to it. 1341 // Create node 1 and assign a view from connection 2 to it.
1340 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1342 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1341 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1343 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1342 ASSERT_TRUE(connection2_->CreateView(BuildViewId(2, 11))); 1344 ASSERT_TRUE(connection2_->CreateView(BuildViewId(2, 11)));
1343 ASSERT_TRUE(connection2_->SetView(BuildNodeId(1, 1), BuildViewId(2, 11))); 1345 ASSERT_TRUE(connection2_->SetView(BuildNodeId(1, 1), BuildViewId(2, 11)));
1344 1346
1345 // Dispatch an event to the view and verify its received. 1347 // Dispatch an event to the view and verify its received.
1346 { 1348 {
1347 EventPtr event(Event::New()); 1349 EventPtr event(Event::New());
1348 event->action = 1; 1350 event->action = 1;
(...skipping 10 matching lines...) Expand all
1359 // TODO(sky): add coverage of test that destroys connections and ensures other 1361 // TODO(sky): add coverage of test that destroys connections and ensures other
1360 // connections get deletion notification (or advanced server id). 1362 // connections get deletion notification (or advanced server id).
1361 1363
1362 // TODO(sky): need to better track changes to initial connection. For example, 1364 // TODO(sky): need to better track changes to initial connection. For example,
1363 // that SetBounsdNodes/AddNode and the like don't result in messages to the 1365 // that SetBounsdNodes/AddNode and the like don't result in messages to the
1364 // originating connection. 1366 // originating connection.
1365 1367
1366 } // namespace service 1368 } // namespace service
1367 } // namespace view_manager 1369 } // namespace view_manager
1368 } // namespace mojo 1370 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698