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/auto_reset.h" | 8 #include "base/auto_reset.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 ASSERT_EQ(1u, changes.size()); | 913 ASSERT_EQ(1u, changes.size()); |
914 EXPECT_EQ("HierarchyChanged change_id=1 node=1,2 new_parent=1,1 " | 914 EXPECT_EQ("HierarchyChanged change_id=1 node=1,2 new_parent=1,1 " |
915 "old_parent=null", changes[0]); | 915 "old_parent=null", changes[0]); |
916 } | 916 } |
917 | 917 |
918 // Delete 2. | 918 // Delete 2. |
919 { | 919 { |
920 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 2))); | 920 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 2))); |
921 EXPECT_TRUE(connection_->changes().empty()); | 921 EXPECT_TRUE(connection_->changes().empty()); |
922 | 922 |
923 // TODO(sky): fix this, client should not get ServerChangeIdAdvanced. | 923 connection2_->DoRunLoopUntilChangesCount(1); |
924 connection2_->DoRunLoopUntilChangesCount(2); | |
925 const Changes changes(ChangesToDescription1(connection2_->changes())); | 924 const Changes changes(ChangesToDescription1(connection2_->changes())); |
926 ASSERT_EQ(2u, changes.size()); | 925 ASSERT_EQ(1u, changes.size()); |
927 EXPECT_EQ("NodeDeleted change_id=2 node=1,2", changes[0]); | 926 EXPECT_EQ("NodeDeleted change_id=2 node=1,2", changes[0]); |
928 EXPECT_EQ("ServerChangeIdAdvanced 3", changes[1]); | |
929 } | 927 } |
930 } | 928 } |
931 | 929 |
932 // Verifies DeleteNode isn't allowed from a separate connection. | 930 // Verifies DeleteNode isn't allowed from a separate connection. |
933 TEST_F(ViewManagerConnectionTest, DeleteNodeFromAnotherConnectionDisallowed) { | 931 TEST_F(ViewManagerConnectionTest, DeleteNodeFromAnotherConnectionDisallowed) { |
934 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); | 932 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
935 EXPECT_FALSE(connection2_->DeleteNode(BuildNodeId(1, 1))); | 933 EXPECT_FALSE(connection2_->DeleteNode(BuildNodeId(1, 1))); |
936 } | 934 } |
937 | 935 |
938 // Verifies DeleteView isn't allowed from a separate connection. | 936 // Verifies DeleteView isn't allowed from a separate connection. |
(...skipping 19 matching lines...) Expand all Loading... |
958 "HierarchyChanged change_id=1 node=1,2 new_parent=1,1 old_parent=null", | 956 "HierarchyChanged change_id=1 node=1,2 new_parent=1,1 old_parent=null", |
959 changes[0]); | 957 changes[0]); |
960 EXPECT_EQ("[node=1,2 parent=1,1 view=null]", | 958 EXPECT_EQ("[node=1,2 parent=1,1 view=null]", |
961 ChangeNodeDescription(connection2_->changes())); | 959 ChangeNodeDescription(connection2_->changes())); |
962 } | 960 } |
963 | 961 |
964 // Delete 2. | 962 // Delete 2. |
965 { | 963 { |
966 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 2))); | 964 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 2))); |
967 | 965 |
968 // TODO(sky): fix this, shouldn't get ServerChangeIdAdvanced. | 966 connection2_->DoRunLoopUntilChangesCount(1); |
969 connection2_->DoRunLoopUntilChangesCount(2); | |
970 const Changes changes(ChangesToDescription1(connection2_->changes())); | 967 const Changes changes(ChangesToDescription1(connection2_->changes())); |
971 ASSERT_EQ(2u, changes.size()); | 968 ASSERT_EQ(1u, changes.size()); |
972 EXPECT_EQ("NodeDeleted change_id=2 node=1,2", changes[0]); | 969 EXPECT_EQ("NodeDeleted change_id=2 node=1,2", changes[0]); |
973 EXPECT_EQ("ServerChangeIdAdvanced 3", changes[1]); | |
974 } | 970 } |
975 | 971 |
976 // Create 2 again, and add it back to 1. Should get the same notification. | 972 // Create 2 again, and add it back to 1. Should get the same notification. |
977 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); | 973 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); |
978 { | 974 { |
979 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 3)); | 975 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 3)); |
980 | 976 |
981 connection2_->DoRunLoopUntilChangesCount(1); | 977 connection2_->DoRunLoopUntilChangesCount(1); |
982 const Changes changes(ChangesToDescription1(connection2_->changes())); | 978 const Changes changes(ChangesToDescription1(connection2_->changes())); |
983 EXPECT_EQ( | 979 EXPECT_EQ( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 connection2_->DoRunLoopUntilChangesCount(1); | 1056 connection2_->DoRunLoopUntilChangesCount(1); |
1061 const Changes changes(ChangesToDescription1(connection2_->changes())); | 1057 const Changes changes(ChangesToDescription1(connection2_->changes())); |
1062 ASSERT_EQ(1u, changes.size()); | 1058 ASSERT_EQ(1u, changes.size()); |
1063 EXPECT_EQ("ViewReplaced node=1,3 new_view=1,11 old_view=null", changes[0]); | 1059 EXPECT_EQ("ViewReplaced node=1,3 new_view=1,11 old_view=null", changes[0]); |
1064 } | 1060 } |
1065 | 1061 |
1066 // Delete 3. | 1062 // Delete 3. |
1067 { | 1063 { |
1068 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 3))); | 1064 ASSERT_TRUE(connection_->DeleteNode(BuildNodeId(1, 3))); |
1069 | 1065 |
1070 // TODO(sky): shouldn't get ServerChangeIdAdvanced here. | 1066 connection2_->DoRunLoopUntilChangesCount(1); |
1071 connection2_->DoRunLoopUntilChangesCount(2); | |
1072 const Changes changes(ChangesToDescription1(connection2_->changes())); | 1067 const Changes changes(ChangesToDescription1(connection2_->changes())); |
1073 ASSERT_EQ(2u, changes.size()); | 1068 ASSERT_EQ(1u, changes.size()); |
1074 EXPECT_EQ("NodeDeleted change_id=3 node=1,3", changes[0]); | 1069 EXPECT_EQ("NodeDeleted change_id=3 node=1,3", changes[0]); |
1075 EXPECT_EQ("ServerChangeIdAdvanced 4", changes[1]); | |
1076 } | 1070 } |
1077 } | 1071 } |
1078 | 1072 |
1079 // Sets view from one connection on another. | 1073 // Sets view from one connection on another. |
1080 TEST_F(ViewManagerConnectionTest, SetViewFromSecondConnection) { | 1074 TEST_F(ViewManagerConnectionTest, SetViewFromSecondConnection) { |
1081 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); | 1075 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
1082 | 1076 |
1083 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); | 1077 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); |
1084 | 1078 |
1085 // Create a view in the second connection. | 1079 // Create a view in the second connection. |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 // TODO(sky): add coverage of test that destroys connections and ensures other | 1341 // TODO(sky): add coverage of test that destroys connections and ensures other |
1348 // connections get deletion notification (or advanced server id). | 1342 // connections get deletion notification (or advanced server id). |
1349 | 1343 |
1350 // TODO(sky): need to better track changes to initial connection. For example, | 1344 // TODO(sky): need to better track changes to initial connection. For example, |
1351 // that SetBounsdNodes/AddNode and the like don't result in messages to the | 1345 // that SetBounsdNodes/AddNode and the like don't result in messages to the |
1352 // originating connection. | 1346 // originating connection. |
1353 | 1347 |
1354 } // namespace service | 1348 } // namespace service |
1355 } // namespace view_manager | 1349 } // namespace view_manager |
1356 } // namespace mojo | 1350 } // namespace mojo |
OLD | NEW |