| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 const std::vector<Change>& changes() const { return changes_; } | 79 const std::vector<Change>& changes() const { return changes_; } |
| 80 | 80 |
| 81 // Destroys the connection, blocking until done. | 81 // Destroys the connection, blocking until done. |
| 82 void Destroy() { | 82 void Destroy() { |
| 83 router_->CloseMessagePipe(); | 83 router_->CloseMessagePipe(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // The following functions are cover methods for IViewManager. They block | 86 // The following functions are cover methods for IViewManager. They block |
| 87 // until the result is received. | 87 // until the result is received. |
| 88 bool CreateNode(TransportNodeId node_id) { | 88 bool CreateNode(Id node_id) { |
| 89 changes_.clear(); | 89 changes_.clear(); |
| 90 bool result = false; | 90 bool result = false; |
| 91 view_manager_->CreateNode(node_id, | 91 view_manager_->CreateNode(node_id, |
| 92 base::Bind(&ViewManagerProxy::GotResult, | 92 base::Bind(&ViewManagerProxy::GotResult, |
| 93 base::Unretained(this), &result)); | 93 base::Unretained(this), &result)); |
| 94 RunMainLoop(); | 94 RunMainLoop(); |
| 95 return result; | 95 return result; |
| 96 } | 96 } |
| 97 bool AddNode(TransportNodeId parent, | 97 bool AddNode(Id parent, Id child, Id server_change_id) { |
| 98 TransportNodeId child, | |
| 99 TransportChangeId server_change_id) { | |
| 100 changes_.clear(); | 98 changes_.clear(); |
| 101 bool result = false; | 99 bool result = false; |
| 102 view_manager_->AddNode(parent, child, server_change_id, | 100 view_manager_->AddNode(parent, child, server_change_id, |
| 103 base::Bind(&ViewManagerProxy::GotResult, | 101 base::Bind(&ViewManagerProxy::GotResult, |
| 104 base::Unretained(this), &result)); | 102 base::Unretained(this), &result)); |
| 105 RunMainLoop(); | 103 RunMainLoop(); |
| 106 return result; | 104 return result; |
| 107 } | 105 } |
| 108 bool RemoveNodeFromParent(TransportNodeId node_id, | 106 bool RemoveNodeFromParent(Id node_id, Id server_change_id) { |
| 109 TransportChangeId server_change_id) { | |
| 110 changes_.clear(); | 107 changes_.clear(); |
| 111 bool result = false; | 108 bool result = false; |
| 112 view_manager_->RemoveNodeFromParent(node_id, server_change_id, | 109 view_manager_->RemoveNodeFromParent(node_id, server_change_id, |
| 113 base::Bind(&ViewManagerProxy::GotResult, | 110 base::Bind(&ViewManagerProxy::GotResult, |
| 114 base::Unretained(this), &result)); | 111 base::Unretained(this), &result)); |
| 115 RunMainLoop(); | 112 RunMainLoop(); |
| 116 return result; | 113 return result; |
| 117 } | 114 } |
| 118 bool SetView(TransportNodeId node_id, TransportViewId view_id) { | 115 bool SetView(Id node_id, Id view_id) { |
| 119 changes_.clear(); | 116 changes_.clear(); |
| 120 bool result = false; | 117 bool result = false; |
| 121 view_manager_->SetView(node_id, view_id, | 118 view_manager_->SetView(node_id, view_id, |
| 122 base::Bind(&ViewManagerProxy::GotResult, | 119 base::Bind(&ViewManagerProxy::GotResult, |
| 123 base::Unretained(this), &result)); | 120 base::Unretained(this), &result)); |
| 124 RunMainLoop(); | 121 RunMainLoop(); |
| 125 return result; | 122 return result; |
| 126 } | 123 } |
| 127 bool CreateView(TransportViewId view_id) { | 124 bool CreateView(Id view_id) { |
| 128 changes_.clear(); | 125 changes_.clear(); |
| 129 bool result = false; | 126 bool result = false; |
| 130 view_manager_->CreateView(view_id, | 127 view_manager_->CreateView(view_id, |
| 131 base::Bind(&ViewManagerProxy::GotResult, | 128 base::Bind(&ViewManagerProxy::GotResult, |
| 132 base::Unretained(this), &result)); | 129 base::Unretained(this), &result)); |
| 133 RunMainLoop(); | 130 RunMainLoop(); |
| 134 return result; | 131 return result; |
| 135 } | 132 } |
| 136 void GetNodeTree(TransportNodeId node_id, std::vector<TestNode>* nodes) { | 133 void GetNodeTree(Id node_id, std::vector<TestNode>* nodes) { |
| 137 changes_.clear(); | 134 changes_.clear(); |
| 138 view_manager_->GetNodeTree(node_id, | 135 view_manager_->GetNodeTree(node_id, |
| 139 base::Bind(&ViewManagerProxy::GotNodeTree, | 136 base::Bind(&ViewManagerProxy::GotNodeTree, |
| 140 base::Unretained(this), nodes)); | 137 base::Unretained(this), nodes)); |
| 141 RunMainLoop(); | 138 RunMainLoop(); |
| 142 } | 139 } |
| 143 bool Connect(const std::vector<TransportNodeId>& nodes) { | 140 bool Connect(const std::vector<Id>& nodes) { |
| 144 changes_.clear(); | 141 changes_.clear(); |
| 145 base::AutoReset<bool> auto_reset(&in_connect_, true); | 142 base::AutoReset<bool> auto_reset(&in_connect_, true); |
| 146 bool result = false; | 143 bool result = false; |
| 147 view_manager_->Connect(kTestServiceURL, Array<TransportNodeId>::From(nodes), | 144 view_manager_->Connect(kTestServiceURL, Array<Id>::From(nodes), |
| 148 base::Bind(&ViewManagerProxy::GotResult, | 145 base::Bind(&ViewManagerProxy::GotResult, |
| 149 base::Unretained(this), &result)); | 146 base::Unretained(this), &result)); |
| 150 RunMainLoop(); | 147 RunMainLoop(); |
| 151 return result; | 148 return result; |
| 152 } | 149 } |
| 153 bool DeleteNode(TransportNodeId node_id) { | 150 bool DeleteNode(Id node_id) { |
| 154 changes_.clear(); | 151 changes_.clear(); |
| 155 bool result = false; | 152 bool result = false; |
| 156 view_manager_->DeleteNode(node_id, | 153 view_manager_->DeleteNode(node_id, |
| 157 base::Bind(&ViewManagerProxy::GotResult, | 154 base::Bind(&ViewManagerProxy::GotResult, |
| 158 base::Unretained(this), &result)); | 155 base::Unretained(this), &result)); |
| 159 RunMainLoop(); | 156 RunMainLoop(); |
| 160 return result; | 157 return result; |
| 161 } | 158 } |
| 162 bool DeleteView(TransportViewId view_id) { | 159 bool DeleteView(Id view_id) { |
| 163 changes_.clear(); | 160 changes_.clear(); |
| 164 bool result = false; | 161 bool result = false; |
| 165 view_manager_->DeleteView(view_id, | 162 view_manager_->DeleteView(view_id, |
| 166 base::Bind(&ViewManagerProxy::GotResult, | 163 base::Bind(&ViewManagerProxy::GotResult, |
| 167 base::Unretained(this), &result)); | 164 base::Unretained(this), &result)); |
| 168 RunMainLoop(); | 165 RunMainLoop(); |
| 169 return result; | 166 return result; |
| 170 } | 167 } |
| 171 bool SetNodeBounds(TransportNodeId node_id, const gfx::Rect& bounds) { | 168 bool SetNodeBounds(Id node_id, const gfx::Rect& bounds) { |
| 172 changes_.clear(); | 169 changes_.clear(); |
| 173 bool result = false; | 170 bool result = false; |
| 174 view_manager_->SetNodeBounds(node_id, Rect::From(bounds), | 171 view_manager_->SetNodeBounds(node_id, Rect::From(bounds), |
| 175 base::Bind(&ViewManagerProxy::GotResult, | 172 base::Bind(&ViewManagerProxy::GotResult, |
| 176 base::Unretained(this), &result)); | 173 base::Unretained(this), &result)); |
| 177 RunMainLoop(); | 174 RunMainLoop(); |
| 178 return result; | 175 return result; |
| 179 } | 176 } |
| 180 | 177 |
| 181 private: | 178 private: |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 271 } |
| 275 | 272 |
| 276 // InterfaceImp: | 273 // InterfaceImp: |
| 277 virtual void OnConnectionEstablished() OVERRIDE { | 274 virtual void OnConnectionEstablished() OVERRIDE { |
| 278 connection_.set_router(internal_state()->router()); | 275 connection_.set_router(internal_state()->router()); |
| 279 connection_.set_view_manager(client()); | 276 connection_.set_view_manager(client()); |
| 280 } | 277 } |
| 281 | 278 |
| 282 // IViewMangerClient: | 279 // IViewMangerClient: |
| 283 virtual void OnViewManagerConnectionEstablished( | 280 virtual void OnViewManagerConnectionEstablished( |
| 284 TransportConnectionId connection_id, | 281 ConnectionSpecificId connection_id, |
| 285 TransportChangeId next_server_change_id, | 282 Id next_server_change_id, |
| 286 Array<INodePtr> nodes) OVERRIDE { | 283 Array<INodePtr> nodes) OVERRIDE { |
| 287 tracker_.OnViewManagerConnectionEstablished( | 284 tracker_.OnViewManagerConnectionEstablished( |
| 288 connection_id, next_server_change_id, nodes.Pass()); | 285 connection_id, next_server_change_id, nodes.Pass()); |
| 289 } | 286 } |
| 290 virtual void OnRootsAdded(Array<INodePtr> nodes) OVERRIDE { | 287 virtual void OnRootsAdded(Array<INodePtr> nodes) OVERRIDE { |
| 291 tracker_.OnRootsAdded(nodes.Pass()); | 288 tracker_.OnRootsAdded(nodes.Pass()); |
| 292 } | 289 } |
| 293 virtual void OnServerChangeIdAdvanced( | 290 virtual void OnServerChangeIdAdvanced( |
| 294 TransportChangeId next_server_change_id) OVERRIDE { | 291 Id next_server_change_id) OVERRIDE { |
| 295 tracker_.OnServerChangeIdAdvanced(next_server_change_id); | 292 tracker_.OnServerChangeIdAdvanced(next_server_change_id); |
| 296 } | 293 } |
| 297 virtual void OnNodeBoundsChanged(TransportNodeId node_id, | 294 virtual void OnNodeBoundsChanged(Id node_id, |
| 298 RectPtr old_bounds, | 295 RectPtr old_bounds, |
| 299 RectPtr new_bounds) OVERRIDE { | 296 RectPtr new_bounds) OVERRIDE { |
| 300 tracker_.OnNodeBoundsChanged(node_id, old_bounds.Pass(), new_bounds.Pass()); | 297 tracker_.OnNodeBoundsChanged(node_id, old_bounds.Pass(), new_bounds.Pass()); |
| 301 } | 298 } |
| 302 virtual void OnNodeHierarchyChanged( | 299 virtual void OnNodeHierarchyChanged(Id node, |
| 303 TransportNodeId node, | 300 Id new_parent, |
| 304 TransportNodeId new_parent, | 301 Id old_parent, |
| 305 TransportNodeId old_parent, | 302 Id server_change_id, |
| 306 TransportChangeId server_change_id, | 303 Array<INodePtr> nodes) OVERRIDE { |
| 307 Array<INodePtr> nodes) OVERRIDE { | |
| 308 tracker_.OnNodeHierarchyChanged(node, new_parent, old_parent, | 304 tracker_.OnNodeHierarchyChanged(node, new_parent, old_parent, |
| 309 server_change_id, nodes.Pass()); | 305 server_change_id, nodes.Pass()); |
| 310 } | 306 } |
| 311 virtual void OnNodeDeleted(TransportNodeId node, | 307 virtual void OnNodeDeleted(Id node, Id server_change_id) OVERRIDE { |
| 312 TransportChangeId server_change_id) OVERRIDE { | |
| 313 tracker_.OnNodeDeleted(node, server_change_id); | 308 tracker_.OnNodeDeleted(node, server_change_id); |
| 314 } | 309 } |
| 315 virtual void OnViewDeleted(TransportViewId view) OVERRIDE { | 310 virtual void OnViewDeleted(Id view) OVERRIDE { |
| 316 tracker_.OnViewDeleted(view); | 311 tracker_.OnViewDeleted(view); |
| 317 } | 312 } |
| 318 virtual void OnNodeViewReplaced(TransportNodeId node, | 313 virtual void OnNodeViewReplaced(Id node, |
| 319 TransportViewId new_view_id, | 314 Id new_view_id, |
| 320 TransportViewId old_view_id) OVERRIDE { | 315 Id old_view_id) OVERRIDE { |
| 321 tracker_.OnNodeViewReplaced(node, new_view_id, old_view_id); | 316 tracker_.OnNodeViewReplaced(node, new_view_id, old_view_id); |
| 322 } | 317 } |
| 323 virtual void OnViewInputEvent(TransportViewId view_id, | 318 virtual void OnViewInputEvent(Id view_id, |
| 324 EventPtr event, | 319 EventPtr event, |
| 325 const Callback<void()>& callback) OVERRIDE { | 320 const Callback<void()>& callback) OVERRIDE { |
| 326 tracker_.OnViewInputEvent(view_id, event.Pass()); | 321 tracker_.OnViewInputEvent(view_id, event.Pass()); |
| 327 } | 322 } |
| 328 | 323 |
| 329 private: | 324 private: |
| 330 TestChangeTracker tracker_; | 325 TestChangeTracker tracker_; |
| 331 ViewManagerProxy connection_; | 326 ViewManagerProxy connection_; |
| 332 | 327 |
| 333 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); | 328 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 352 const GURL& url) OVERRIDE { | 347 const GURL& url) OVERRIDE { |
| 353 } | 348 } |
| 354 | 349 |
| 355 private: | 350 private: |
| 356 ScopedVector<Application> apps_; | 351 ScopedVector<Application> apps_; |
| 357 | 352 |
| 358 DISALLOW_COPY_AND_ASSIGN(ConnectServiceLoader); | 353 DISALLOW_COPY_AND_ASSIGN(ConnectServiceLoader); |
| 359 }; | 354 }; |
| 360 | 355 |
| 361 // Creates an id used for transport from the specified parameters. | 356 // Creates an id used for transport from the specified parameters. |
| 362 TransportNodeId BuildNodeId(TransportConnectionId connection_id, | 357 Id BuildNodeId(ConnectionSpecificId connection_id, |
| 363 TransportConnectionSpecificNodeId node_id) { | 358 ConnectionSpecificId node_id) { |
| 364 return (connection_id << 16) | node_id; | 359 return (connection_id << 16) | node_id; |
| 365 } | 360 } |
| 366 | 361 |
| 367 // Creates an id used for transport from the specified parameters. | 362 // Creates an id used for transport from the specified parameters. |
| 368 TransportViewId BuildViewId(TransportConnectionId connection_id, | 363 Id BuildViewId(ConnectionSpecificId connection_id, |
| 369 TransportConnectionSpecificViewId view_id) { | 364 ConnectionSpecificId view_id) { |
| 370 return (connection_id << 16) | view_id; | 365 return (connection_id << 16) | view_id; |
| 371 } | 366 } |
| 372 | 367 |
| 373 // Callback from ViewManagerInitConnect(). |result| is the result of the | 368 // Callback from ViewManagerInitConnect(). |result| is the result of the |
| 374 // Connect() call and |run_loop| the nested RunLoop. | 369 // Connect() call and |run_loop| the nested RunLoop. |
| 375 void ViewManagerInitConnectCallback(bool* result_cache, | 370 void ViewManagerInitConnectCallback(bool* result_cache, |
| 376 base::RunLoop* run_loop, | 371 base::RunLoop* run_loop, |
| 377 bool result) { | 372 bool result) { |
| 378 *result_cache = result; | 373 *result_cache = result; |
| 379 run_loop->Quit(); | 374 run_loop->Quit(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 414 } |
| 420 | 415 |
| 421 virtual void TearDown() OVERRIDE { | 416 virtual void TearDown() OVERRIDE { |
| 422 if (connection2_) | 417 if (connection2_) |
| 423 connection2_->Destroy(); | 418 connection2_->Destroy(); |
| 424 if (connection_) | 419 if (connection_) |
| 425 connection_->Destroy(); | 420 connection_->Destroy(); |
| 426 } | 421 } |
| 427 | 422 |
| 428 protected: | 423 protected: |
| 429 void EstablishSecondConnectionWithRoots( | 424 void EstablishSecondConnectionWithRoots(Id id1, Id id2) { |
| 430 TransportNodeId id1, | 425 std::vector<Id> node_ids; |
| 431 TransportNodeId id2) { | |
| 432 std::vector<TransportNodeId> node_ids; | |
| 433 node_ids.push_back(id1); | 426 node_ids.push_back(id1); |
| 434 if (id2 != 0) | 427 if (id2 != 0) |
| 435 node_ids.push_back(id2); | 428 node_ids.push_back(id2); |
| 436 ASSERT_TRUE(connection_->Connect(node_ids)); | 429 ASSERT_TRUE(connection_->Connect(node_ids)); |
| 437 connection2_ = ViewManagerProxy::WaitForInstance(); | 430 connection2_ = ViewManagerProxy::WaitForInstance(); |
| 438 ASSERT_TRUE(connection2_ != NULL); | 431 ASSERT_TRUE(connection2_ != NULL); |
| 439 connection2_->DoRunLoopUntilChangesCount(1); | 432 connection2_->DoRunLoopUntilChangesCount(1); |
| 440 ASSERT_EQ(1u, connection2_->changes().size()); | 433 ASSERT_EQ(1u, connection2_->changes().size()); |
| 441 } | 434 } |
| 442 | 435 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // Verifies client gets a valid id. | 467 // Verifies client gets a valid id. |
| 475 TEST_F(ViewManagerConnectionTest, ValidId) { | 468 TEST_F(ViewManagerConnectionTest, ValidId) { |
| 476 EXPECT_EQ("OnConnectionEstablished", | 469 EXPECT_EQ("OnConnectionEstablished", |
| 477 ChangesToDescription1(connection_->changes())[0]); | 470 ChangesToDescription1(connection_->changes())[0]); |
| 478 | 471 |
| 479 // All these tests assume 1 for the client id. The only real assertion here is | 472 // All these tests assume 1 for the client id. The only real assertion here is |
| 480 // the client id is not zero, but adding this as rest of code here assumes 1. | 473 // the client id is not zero, but adding this as rest of code here assumes 1. |
| 481 EXPECT_EQ(1, connection_->changes()[0].connection_id); | 474 EXPECT_EQ(1, connection_->changes()[0].connection_id); |
| 482 | 475 |
| 483 // Change ids start at 1 as well. | 476 // Change ids start at 1 as well. |
| 484 EXPECT_EQ(static_cast<TransportChangeId>(1), | 477 EXPECT_EQ(static_cast<Id>(1), connection_->changes()[0].change_id); |
| 485 connection_->changes()[0].change_id); | |
| 486 } | 478 } |
| 487 | 479 |
| 488 // Verifies two clients/connections get different ids. | 480 // Verifies two clients/connections get different ids. |
| 489 TEST_F(ViewManagerConnectionTest, TwoClientsGetDifferentConnectionIds) { | 481 TEST_F(ViewManagerConnectionTest, TwoClientsGetDifferentConnectionIds) { |
| 490 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); | 482 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); |
| 491 EXPECT_EQ("OnConnectionEstablished", | 483 EXPECT_EQ("OnConnectionEstablished", |
| 492 ChangesToDescription1(connection2_->changes())[0]); | 484 ChangesToDescription1(connection2_->changes())[0]); |
| 493 | 485 |
| 494 // It isn't strickly necessary that the second connection gets 2, but these | 486 // It isn't strickly necessary that the second connection gets 2, but these |
| 495 // tests are written assuming that is the case. The key thing is the | 487 // tests are written assuming that is the case. The key thing is the |
| 496 // connection ids of |connection_| and |connection2_| differ. | 488 // connection ids of |connection_| and |connection2_| differ. |
| 497 EXPECT_EQ(2, connection2_->changes()[0].connection_id); | 489 EXPECT_EQ(2, connection2_->changes()[0].connection_id); |
| 498 | 490 |
| 499 // Change ids start at 1 as well. | 491 // Change ids start at 1 as well. |
| 500 EXPECT_EQ(static_cast<TransportChangeId>(1), | 492 EXPECT_EQ(static_cast<Id>(1), connection2_->changes()[0].change_id); |
| 501 connection2_->changes()[0].change_id); | |
| 502 } | 493 } |
| 503 | 494 |
| 504 // Verifies client gets a valid id. | 495 // Verifies client gets a valid id. |
| 505 TEST_F(ViewManagerConnectionTest, CreateNode) { | 496 TEST_F(ViewManagerConnectionTest, CreateNode) { |
| 506 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); | 497 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); |
| 507 EXPECT_TRUE(connection_->changes().empty()); | 498 EXPECT_TRUE(connection_->changes().empty()); |
| 508 | 499 |
| 509 // Can't create a node with the same id. | 500 // Can't create a node with the same id. |
| 510 ASSERT_FALSE(connection_->CreateNode(BuildNodeId(1, 1))); | 501 ASSERT_FALSE(connection_->CreateNode(BuildNodeId(1, 1))); |
| 511 EXPECT_TRUE(connection_->changes().empty()); | 502 EXPECT_TRUE(connection_->changes().empty()); |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 } | 1197 } |
| 1207 | 1198 |
| 1208 TEST_F(ViewManagerConnectionTest, ConnectTwice) { | 1199 TEST_F(ViewManagerConnectionTest, ConnectTwice) { |
| 1209 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); | 1200 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); |
| 1210 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); | 1201 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); |
| 1211 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); | 1202 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); |
| 1212 | 1203 |
| 1213 // Try to connect again to 1,1, this should fail as already connected to that | 1204 // Try to connect again to 1,1, this should fail as already connected to that |
| 1214 // root. | 1205 // root. |
| 1215 { | 1206 { |
| 1216 std::vector<TransportNodeId> node_ids; | 1207 std::vector<Id> node_ids; |
| 1217 node_ids.push_back(BuildNodeId(1, 1)); | 1208 node_ids.push_back(BuildNodeId(1, 1)); |
| 1218 ASSERT_FALSE(connection_->Connect(node_ids)); | 1209 ASSERT_FALSE(connection_->Connect(node_ids)); |
| 1219 } | 1210 } |
| 1220 | 1211 |
| 1221 // Connecting to 1,2 should succeed and end up in connection2. | 1212 // Connecting to 1,2 should succeed and end up in connection2. |
| 1222 { | 1213 { |
| 1223 std::vector<TransportNodeId> node_ids; | 1214 std::vector<Id> node_ids; |
| 1224 node_ids.push_back(BuildNodeId(1, 2)); | 1215 node_ids.push_back(BuildNodeId(1, 2)); |
| 1225 ASSERT_TRUE(connection_->Connect(node_ids)); | 1216 ASSERT_TRUE(connection_->Connect(node_ids)); |
| 1226 connection2_->DoRunLoopUntilChangesCount(1); | 1217 connection2_->DoRunLoopUntilChangesCount(1); |
| 1227 const Changes changes(ChangesToDescription1(connection2_->changes())); | 1218 const Changes changes(ChangesToDescription1(connection2_->changes())); |
| 1228 ASSERT_EQ(1u, changes.size()); | 1219 ASSERT_EQ(1u, changes.size()); |
| 1229 EXPECT_EQ("OnRootsAdded", changes[0]); | 1220 EXPECT_EQ("OnRootsAdded", changes[0]); |
| 1230 EXPECT_EQ("[node=1,2 parent=null view=null]", | 1221 EXPECT_EQ("[node=1,2 parent=null view=null]", |
| 1231 ChangeNodeDescription(connection2_->changes())); | 1222 ChangeNodeDescription(connection2_->changes())); |
| 1232 } | 1223 } |
| 1233 } | 1224 } |
| 1234 | 1225 |
| 1235 // TODO(sky): add coverage of test that destroys connections and ensures other | 1226 // TODO(sky): add coverage of test that destroys connections and ensures other |
| 1236 // connections get deletion notification (or advanced server id). | 1227 // connections get deletion notification (or advanced server id). |
| 1237 | 1228 |
| 1238 // TODO(sky): need to better track changes to initial connection. For example, | 1229 // TODO(sky): need to better track changes to initial connection. For example, |
| 1239 // that SetBounsdNodes/AddNode and the like don't result in messages to the | 1230 // that SetBounsdNodes/AddNode and the like don't result in messages to the |
| 1240 // originating connection. | 1231 // originating connection. |
| 1241 | 1232 |
| 1242 } // namespace service | 1233 } // namespace service |
| 1243 } // namespace view_manager | 1234 } // namespace view_manager |
| 1244 } // namespace mojo | 1235 } // namespace mojo |
| OLD | NEW |