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

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

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more Created 6 years, 7 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
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/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "mojo/public/cpp/bindings/allocation_scope.h"
14 #include "mojo/public/cpp/environment/environment.h" 13 #include "mojo/public/cpp/environment/environment.h"
15 #include "mojo/public/cpp/shell/connect.h" 14 #include "mojo/public/cpp/shell/connect.h"
16 #include "mojo/services/public/cpp/view_manager/util.h" 15 #include "mojo/services/public/cpp/view_manager/util.h"
17 #include "mojo/services/public/cpp/view_manager/view_manager_types.h" 16 #include "mojo/services/public/cpp/view_manager/view_manager_types.h"
18 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" 17 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
19 #include "mojo/shell/shell_test_helper.h" 18 #include "mojo/shell/shell_test_helper.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 20
22 namespace mojo { 21 namespace mojo {
23 namespace view_manager { 22 namespace view_manager {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 NodeIdToString(node_id).c_str(), 54 NodeIdToString(node_id).c_str(),
56 NodeIdToString(parent_id).c_str(), 55 NodeIdToString(parent_id).c_str(),
57 NodeIdToString(view_id).c_str()); 56 NodeIdToString(view_id).c_str());
58 } 57 }
59 58
60 TransportNodeId parent_id; 59 TransportNodeId parent_id;
61 TransportNodeId node_id; 60 TransportNodeId node_id;
62 TransportNodeId view_id; 61 TransportNodeId view_id;
63 }; 62 };
64 63
65 void INodesToTestNodes(const mojo::Array<INode>& data, 64 void INodesToTestNodes(const mojo::Array<INodePtr>& data,
66 std::vector<TestNode>* test_nodes) { 65 std::vector<TestNode>* test_nodes) {
67 for (size_t i = 0; i < data.size(); ++i) { 66 for (size_t i = 0; i < data.size(); ++i) {
68 TestNode node; 67 TestNode node;
69 node.parent_id = data[i].parent_id(); 68 node.parent_id = data[i]->parent_id;
70 node.node_id = data[i].node_id(); 69 node.node_id = data[i]->node_id;
71 node.view_id = data[i].view_id(); 70 node.view_id = data[i]->view_id;
72 test_nodes->push_back(node); 71 test_nodes->push_back(node);
73 } 72 }
74 } 73 }
75 74
76 // Callback that results in a vector of INodes. The INodes are converted to 75 // Callback that results in a vector of INodes. The INodes are converted to
77 // TestNodes. 76 // TestNodes.
78 void INodesCallback(std::vector<TestNode>* test_nodes, 77 void INodesCallback(std::vector<TestNode>* test_nodes,
79 const mojo::Array<INode>& data) { 78 mojo::Array<INodePtr> data) {
80 INodesToTestNodes(data, test_nodes); 79 INodesToTestNodes(data, test_nodes);
81 current_run_loop->Quit(); 80 current_run_loop->Quit();
82 } 81 }
83 82
84 // Creates an id used for transport from the specified parameters. 83 // Creates an id used for transport from the specified parameters.
85 TransportNodeId CreateNodeId(TransportConnectionId connection_id, 84 TransportNodeId CreateNodeId(TransportConnectionId connection_id,
86 TransportConnectionSpecificNodeId node_id) { 85 TransportConnectionSpecificNodeId node_id) {
87 return (connection_id << 16) | node_id; 86 return (connection_id << 16) | node_id;
88 } 87 }
89 88
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 return; 213 return;
215 quit_count_ = count - changes_.size(); 214 quit_count_ = count - changes_.size();
216 DoRunLoop(); 215 DoRunLoop();
217 } 216 }
218 217
219 private: 218 private:
220 // IViewManagerClient overrides: 219 // IViewManagerClient overrides:
221 virtual void OnConnectionEstablished( 220 virtual void OnConnectionEstablished(
222 TransportConnectionId connection_id, 221 TransportConnectionId connection_id,
223 TransportChangeId next_server_change_id, 222 TransportChangeId next_server_change_id,
224 const mojo::Array<INode>& nodes) OVERRIDE { 223 mojo::Array<INodePtr> nodes) OVERRIDE {
225 id_ = connection_id; 224 id_ = connection_id;
226 next_server_change_id_ = next_server_change_id; 225 next_server_change_id_ = next_server_change_id;
227 INodesToTestNodes(nodes, &initial_nodes_); 226 INodesToTestNodes(nodes, &initial_nodes_);
228 if (current_run_loop) 227 if (current_run_loop)
229 current_run_loop->Quit(); 228 current_run_loop->Quit();
230 } 229 }
231 virtual void OnServerChangeIdAdvanced( 230 virtual void OnServerChangeIdAdvanced(
232 uint32_t next_server_change_id) OVERRIDE { 231 uint32_t next_server_change_id) OVERRIDE {
233 changes_.push_back( 232 changes_.push_back(
234 base::StringPrintf( 233 base::StringPrintf(
235 "ServerChangeIdAdvanced %d", 234 "ServerChangeIdAdvanced %d",
236 static_cast<int>(next_server_change_id))); 235 static_cast<int>(next_server_change_id)));
237 QuitIfNecessary(); 236 QuitIfNecessary();
238 } 237 }
239 virtual void OnNodeHierarchyChanged( 238 virtual void OnNodeHierarchyChanged(
240 TransportNodeId node, 239 TransportNodeId node,
241 TransportNodeId new_parent, 240 TransportNodeId new_parent,
242 TransportNodeId old_parent, 241 TransportNodeId old_parent,
243 TransportChangeId server_change_id, 242 TransportChangeId server_change_id,
244 const mojo::Array<INode>& nodes) OVERRIDE { 243 mojo::Array<INodePtr> nodes) OVERRIDE {
245 changes_.push_back( 244 changes_.push_back(
246 base::StringPrintf( 245 base::StringPrintf(
247 "HierarchyChanged change_id=%d node=%s new_parent=%s old_parent=%s", 246 "HierarchyChanged change_id=%d node=%s new_parent=%s old_parent=%s",
248 static_cast<int>(server_change_id), 247 static_cast<int>(server_change_id),
249 NodeIdToString(node).c_str(), 248 NodeIdToString(node).c_str(),
250 NodeIdToString(new_parent).c_str(), 249 NodeIdToString(new_parent).c_str(),
251 NodeIdToString(old_parent).c_str())); 250 NodeIdToString(old_parent).c_str()));
252 hierarchy_changed_nodes_.clear(); 251 hierarchy_changed_nodes_.clear();
253 INodesToTestNodes(nodes, &hierarchy_changed_nodes_); 252 INodesToTestNodes(nodes, &hierarchy_changed_nodes_);
254 QuitIfNecessary(); 253 QuitIfNecessary();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 378 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
380 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2)); 379 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2));
381 380
382 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 381 EXPECT_TRUE(client_.GetAndClearChanges().empty());
383 382
384 EstablishSecondConnection(); 383 EstablishSecondConnection();
385 EXPECT_TRUE(client2_.GetAndClearChanges().empty()); 384 EXPECT_TRUE(client2_.GetAndClearChanges().empty());
386 385
387 // Make 2 a child of 1. 386 // Make 2 a child of 1.
388 { 387 {
389 AllocationScope scope;
390 ASSERT_TRUE(AddNode(view_manager_.get(), 388 ASSERT_TRUE(AddNode(view_manager_.get(),
391 CreateNodeId(client_.id(), 1), 389 CreateNodeId(client_.id(), 1),
392 CreateNodeId(client_.id(), 2), 390 CreateNodeId(client_.id(), 2),
393 1)); 391 1));
394 Changes changes(client_.GetAndClearChanges()); 392 Changes changes(client_.GetAndClearChanges());
395 ASSERT_TRUE(changes.empty()); 393 ASSERT_TRUE(changes.empty());
396 394
397 client2_.DoRunLoopUntilChangesCount(1); 395 client2_.DoRunLoopUntilChangesCount(1);
398 changes = client2_.GetAndClearChanges(); 396 changes = client2_.GetAndClearChanges();
399 ASSERT_EQ(1u, changes.size()); 397 ASSERT_EQ(1u, changes.size());
400 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 398 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
401 } 399 }
402 400
403 // Remove 2 from its parent. 401 // Remove 2 from its parent.
404 { 402 {
405 AllocationScope scope;
406 ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(), 403 ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(),
407 CreateNodeId(client_.id(), 2), 404 CreateNodeId(client_.id(), 2),
408 2)); 405 2));
409 Changes changes(client_.GetAndClearChanges()); 406 Changes changes(client_.GetAndClearChanges());
410 ASSERT_TRUE(changes.empty()); 407 ASSERT_TRUE(changes.empty());
411 408
412 client2_.DoRunLoopUntilChangesCount(1); 409 client2_.DoRunLoopUntilChangesCount(1);
413 changes = client2_.GetAndClearChanges(); 410 changes = client2_.GetAndClearChanges();
414 ASSERT_EQ(1u, changes.size()); 411 ASSERT_EQ(1u, changes.size());
415 EXPECT_EQ("ServerChangeIdAdvanced 3", changes[0]); 412 EXPECT_EQ("ServerChangeIdAdvanced 3", changes[0]);
416 } 413 }
417 } 414 }
418 415
419 // Verifies AddNode fails when node is already in position. 416 // Verifies AddNode fails when node is already in position.
420 TEST_F(ViewManagerConnectionTest, AddNodeWithNoChange) { 417 TEST_F(ViewManagerConnectionTest, AddNodeWithNoChange) {
421 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 418 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
422 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2)); 419 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2));
423 420
424 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 421 EXPECT_TRUE(client_.GetAndClearChanges().empty());
425 422
426 EstablishSecondConnection(); 423 EstablishSecondConnection();
427 EXPECT_TRUE(client2_.GetAndClearChanges().empty()); 424 EXPECT_TRUE(client2_.GetAndClearChanges().empty());
428 425
429 // Make 2 a child of 1. 426 // Make 2 a child of 1.
430 { 427 {
431 AllocationScope scope;
432 ASSERT_TRUE(AddNode(view_manager_.get(), 428 ASSERT_TRUE(AddNode(view_manager_.get(),
433 CreateNodeId(client_.id(), 1), 429 CreateNodeId(client_.id(), 1),
434 CreateNodeId(client_.id(), 2), 430 CreateNodeId(client_.id(), 2),
435 1)); 431 1));
436 Changes changes(client_.GetAndClearChanges()); 432 Changes changes(client_.GetAndClearChanges());
437 ASSERT_TRUE(changes.empty()); 433 ASSERT_TRUE(changes.empty());
438 434
439 client2_.DoRunLoopUntilChangesCount(1); 435 client2_.DoRunLoopUntilChangesCount(1);
440 changes = client2_.GetAndClearChanges(); 436 changes = client2_.GetAndClearChanges();
441 ASSERT_EQ(1u, changes.size()); 437 ASSERT_EQ(1u, changes.size());
442 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 438 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
443 } 439 }
444 440
445 // Try again, this should fail. 441 // Try again, this should fail.
446 { 442 {
447 AllocationScope scope;
448 EXPECT_FALSE(AddNode(view_manager_.get(), 443 EXPECT_FALSE(AddNode(view_manager_.get(),
449 CreateNodeId(client_.id(), 1), 444 CreateNodeId(client_.id(), 1),
450 CreateNodeId(client_.id(), 2), 445 CreateNodeId(client_.id(), 2),
451 2)); 446 2));
452 Changes changes(client_.GetAndClearChanges()); 447 Changes changes(client_.GetAndClearChanges());
453 EXPECT_TRUE(changes.empty()); 448 EXPECT_TRUE(changes.empty());
454 } 449 }
455 } 450 }
456 451
457 // Verifies AddNode fails when node is already in position. 452 // Verifies AddNode fails when node is already in position.
458 TEST_F(ViewManagerConnectionTest, AddAncestorFails) { 453 TEST_F(ViewManagerConnectionTest, AddAncestorFails) {
459 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 454 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
460 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2)); 455 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2));
461 456
462 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 457 EXPECT_TRUE(client_.GetAndClearChanges().empty());
463 458
464 EstablishSecondConnection(); 459 EstablishSecondConnection();
465 EXPECT_TRUE(client2_.GetAndClearChanges().empty()); 460 EXPECT_TRUE(client2_.GetAndClearChanges().empty());
466 461
467 // Make 2 a child of 1. 462 // Make 2 a child of 1.
468 { 463 {
469 AllocationScope scope;
470 ASSERT_TRUE(AddNode(view_manager_.get(), 464 ASSERT_TRUE(AddNode(view_manager_.get(),
471 CreateNodeId(client_.id(), 1), 465 CreateNodeId(client_.id(), 1),
472 CreateNodeId(client_.id(), 2), 466 CreateNodeId(client_.id(), 2),
473 1)); 467 1));
474 Changes changes(client_.GetAndClearChanges()); 468 Changes changes(client_.GetAndClearChanges());
475 ASSERT_TRUE(changes.empty()); 469 ASSERT_TRUE(changes.empty());
476 470
477 client2_.DoRunLoopUntilChangesCount(1); 471 client2_.DoRunLoopUntilChangesCount(1);
478 changes = client2_.GetAndClearChanges(); 472 changes = client2_.GetAndClearChanges();
479 ASSERT_EQ(1u, changes.size()); 473 ASSERT_EQ(1u, changes.size());
480 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 474 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
481 } 475 }
482 476
483 // Try to make 1 a child of 2, this should fail since 1 is an ancestor of 2. 477 // Try to make 1 a child of 2, this should fail since 1 is an ancestor of 2.
484 { 478 {
485 AllocationScope scope;
486 EXPECT_FALSE(AddNode(view_manager_.get(), 479 EXPECT_FALSE(AddNode(view_manager_.get(),
487 CreateNodeId(client_.id(), 2), 480 CreateNodeId(client_.id(), 2),
488 CreateNodeId(client_.id(), 1), 481 CreateNodeId(client_.id(), 1),
489 2)); 482 2));
490 Changes changes(client_.GetAndClearChanges()); 483 Changes changes(client_.GetAndClearChanges());
491 EXPECT_TRUE(changes.empty()); 484 EXPECT_TRUE(changes.empty());
492 } 485 }
493 } 486 }
494 487
495 // Verifies adding with an invalid id fails. 488 // Verifies adding with an invalid id fails.
496 TEST_F(ViewManagerConnectionTest, AddWithInvalidServerId) { 489 TEST_F(ViewManagerConnectionTest, AddWithInvalidServerId) {
497 // Create two nodes. 490 // Create two nodes.
498 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 491 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
499 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2)); 492 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2));
500 493
501 // Make 2 a child of 1. Supply an invalid change id, which should fail. 494 // Make 2 a child of 1. Supply an invalid change id, which should fail.
502 { 495 {
503 AllocationScope scope;
504 ASSERT_FALSE(AddNode(view_manager_.get(), 496 ASSERT_FALSE(AddNode(view_manager_.get(),
505 CreateNodeId(client_.id(), 1), 497 CreateNodeId(client_.id(), 1),
506 CreateNodeId(client_.id(), 2), 498 CreateNodeId(client_.id(), 2),
507 0)); 499 0));
508 Changes changes(client_.GetAndClearChanges()); 500 Changes changes(client_.GetAndClearChanges());
509 EXPECT_TRUE(changes.empty()); 501 EXPECT_TRUE(changes.empty());
510 } 502 }
511 } 503 }
512 504
513 // Verifies adding to root sends right notifications. 505 // Verifies adding to root sends right notifications.
514 TEST_F(ViewManagerConnectionTest, AddToRoot) { 506 TEST_F(ViewManagerConnectionTest, AddToRoot) {
515 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 21)); 507 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 21));
516 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 3)); 508 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 3));
517 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 509 EXPECT_TRUE(client_.GetAndClearChanges().empty());
518 510
519 EstablishSecondConnection(); 511 EstablishSecondConnection();
520 EXPECT_TRUE(client2_.GetAndClearChanges().empty()); 512 EXPECT_TRUE(client2_.GetAndClearChanges().empty());
521 513
522 // Make 3 a child of 21. 514 // Make 3 a child of 21.
523 { 515 {
524 AllocationScope scope;
525 ASSERT_TRUE(AddNode(view_manager_.get(), 516 ASSERT_TRUE(AddNode(view_manager_.get(),
526 CreateNodeId(client_.id(), 21), 517 CreateNodeId(client_.id(), 21),
527 CreateNodeId(client_.id(), 3), 518 CreateNodeId(client_.id(), 3),
528 1)); 519 1));
529 Changes changes(client_.GetAndClearChanges()); 520 Changes changes(client_.GetAndClearChanges());
530 ASSERT_TRUE(changes.empty()); 521 ASSERT_TRUE(changes.empty());
531 522
532 client2_.DoRunLoopUntilChangesCount(1); 523 client2_.DoRunLoopUntilChangesCount(1);
533 changes = client2_.GetAndClearChanges(); 524 changes = client2_.GetAndClearChanges();
534 ASSERT_EQ(1u, changes.size()); 525 ASSERT_EQ(1u, changes.size());
535 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 526 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
536 } 527 }
537 528
538 // Make 21 a child of the root. 529 // Make 21 a child of the root.
539 { 530 {
540 AllocationScope scope;
541 ASSERT_TRUE(AddNode(view_manager_.get(), 531 ASSERT_TRUE(AddNode(view_manager_.get(),
542 CreateNodeId(0, 1), 532 CreateNodeId(0, 1),
543 CreateNodeId(client_.id(), 21), 533 CreateNodeId(client_.id(), 21),
544 2)); 534 2));
545 Changes changes(client_.GetAndClearChanges()); 535 Changes changes(client_.GetAndClearChanges());
546 ASSERT_TRUE(changes.empty()); 536 ASSERT_TRUE(changes.empty());
547 537
548 client2_.DoRunLoopUntilChangesCount(1); 538 client2_.DoRunLoopUntilChangesCount(1);
549 changes = client2_.GetAndClearChanges(); 539 changes = client2_.GetAndClearChanges();
550 ASSERT_EQ(1u, changes.size()); 540 ASSERT_EQ(1u, changes.size());
551 EXPECT_EQ( 541 EXPECT_EQ(
552 "HierarchyChanged change_id=2 node=1,21 new_parent=0,1 old_parent=null", 542 "HierarchyChanged change_id=2 node=1,21 new_parent=0,1 old_parent=null",
553 changes[0]); 543 changes[0]);
554 } 544 }
555 } 545 }
556 546
557 // Verifies adding to root sends right notifications. 547 // Verifies adding to root sends right notifications.
558 TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedNodes) { 548 TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedNodes) {
559 // Create nodes 1 and 11 with 1 parented to the root and 11 a child of 1. 549 // Create nodes 1 and 11 with 1 parented to the root and 11 a child of 1.
560 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 550 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
561 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 11)); 551 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 11));
562 552
563 // Make 11 a child of 1. 553 // Make 11 a child of 1.
564 { 554 {
565 AllocationScope scope;
566 ASSERT_TRUE(AddNode(view_manager_.get(), 555 ASSERT_TRUE(AddNode(view_manager_.get(),
567 CreateNodeId(client_.id(), 1), 556 CreateNodeId(client_.id(), 1),
568 CreateNodeId(client_.id(), 11), 557 CreateNodeId(client_.id(), 11),
569 1)); 558 1));
570 ASSERT_TRUE(client_.GetAndClearChanges().empty()); 559 ASSERT_TRUE(client_.GetAndClearChanges().empty());
571 } 560 }
572 561
573 EstablishSecondConnection(); 562 EstablishSecondConnection();
574 563
575 // Make 1 a child of the root. 564 // Make 1 a child of the root.
576 { 565 {
577 AllocationScope scope;
578 ASSERT_TRUE(AddNode(view_manager_.get(), 566 ASSERT_TRUE(AddNode(view_manager_.get(),
579 CreateNodeId(0, 1), 567 CreateNodeId(0, 1),
580 CreateNodeId(client_.id(), 1), 568 CreateNodeId(client_.id(), 1),
581 2)); 569 2));
582 ASSERT_TRUE(client_.GetAndClearChanges().empty()); 570 ASSERT_TRUE(client_.GetAndClearChanges().empty());
583 571
584 // Client 2 should get a hierarchy change that includes the new nodes as it 572 // Client 2 should get a hierarchy change that includes the new nodes as it
585 // has not yet seen them. 573 // has not yet seen them.
586 client2_.DoRunLoopUntilChangesCount(1); 574 client2_.DoRunLoopUntilChangesCount(1);
587 Changes changes(client2_.GetAndClearChanges()); 575 Changes changes(client2_.GetAndClearChanges());
588 ASSERT_EQ(1u, changes.size()); 576 ASSERT_EQ(1u, changes.size());
589 EXPECT_EQ( 577 EXPECT_EQ(
590 "HierarchyChanged change_id=2 node=1,1 new_parent=0,1 old_parent=null", 578 "HierarchyChanged change_id=2 node=1,1 new_parent=0,1 old_parent=null",
591 changes[0]); 579 changes[0]);
592 const std::vector<TestNode>& nodes(client2_.hierarchy_changed_nodes()); 580 const std::vector<TestNode>& nodes(client2_.hierarchy_changed_nodes());
593 ASSERT_EQ(2u, nodes.size()); 581 ASSERT_EQ(2u, nodes.size());
594 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[0].ToString()); 582 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[0].ToString());
595 EXPECT_EQ("node=1,11 parent=1,1 view=null", nodes[1].ToString()); 583 EXPECT_EQ("node=1,11 parent=1,1 view=null", nodes[1].ToString());
596 } 584 }
597 585
598 // Remove 1 from the root. 586 // Remove 1 from the root.
599 { 587 {
600 AllocationScope scope;
601 ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(), 588 ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(),
602 CreateNodeId(client_.id(), 1), 589 CreateNodeId(client_.id(), 1),
603 3)); 590 3));
604 ASSERT_TRUE(client_.GetAndClearChanges().empty()); 591 ASSERT_TRUE(client_.GetAndClearChanges().empty());
605 592
606 client2_.DoRunLoopUntilChangesCount(1); 593 client2_.DoRunLoopUntilChangesCount(1);
607 Changes changes(client2_.GetAndClearChanges()); 594 Changes changes(client2_.GetAndClearChanges());
608 ASSERT_EQ(1u, changes.size()); 595 ASSERT_EQ(1u, changes.size());
609 EXPECT_EQ( 596 EXPECT_EQ(
610 "HierarchyChanged change_id=3 node=1,1 new_parent=null old_parent=0,1", 597 "HierarchyChanged change_id=3 node=1,1 new_parent=null old_parent=0,1",
611 changes[0]); 598 changes[0]);
612 } 599 }
613 600
614 // Create another node, 111, parent it to 11. 601 // Create another node, 111, parent it to 11.
615 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 111)); 602 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 111));
616 { 603 {
617 AllocationScope scope;
618 ASSERT_TRUE(AddNode(view_manager_.get(), 604 ASSERT_TRUE(AddNode(view_manager_.get(),
619 CreateNodeId(client_.id(), 11), 605 CreateNodeId(client_.id(), 11),
620 CreateNodeId(client_.id(), 111), 606 CreateNodeId(client_.id(), 111),
621 4)); 607 4));
622 ASSERT_TRUE(client_.GetAndClearChanges().empty()); 608 ASSERT_TRUE(client_.GetAndClearChanges().empty());
623 609
624 client2_.DoRunLoopUntilChangesCount(1); 610 client2_.DoRunLoopUntilChangesCount(1);
625 Changes changes(client2_.GetAndClearChanges()); 611 Changes changes(client2_.GetAndClearChanges());
626 ASSERT_EQ(1u, changes.size()); 612 ASSERT_EQ(1u, changes.size());
627 // Even though 11 isn't attached to the root client 2 is still notified of 613 // Even though 11 isn't attached to the root client 2 is still notified of
(...skipping 27 matching lines...) Expand all
655 TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedAddingKnownToUnknown) { 641 TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedAddingKnownToUnknown) {
656 // Create the following structure: root -> 1 -> 11 and 2->21 (2 has no 642 // Create the following structure: root -> 1 -> 11 and 2->21 (2 has no
657 // parent). 643 // parent).
658 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 644 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
659 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 11)); 645 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 11));
660 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2)); 646 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2));
661 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 21)); 647 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 21));
662 648
663 // Set up the hierarchy. 649 // Set up the hierarchy.
664 { 650 {
665 AllocationScope scope;
666 ASSERT_TRUE(AddNode(view_manager_.get(), 651 ASSERT_TRUE(AddNode(view_manager_.get(),
667 CreateNodeId(0, 1), 652 CreateNodeId(0, 1),
668 CreateNodeId(client_.id(), 1), 653 CreateNodeId(client_.id(), 1),
669 1)); 654 1));
670 ASSERT_TRUE(AddNode(view_manager_.get(), 655 ASSERT_TRUE(AddNode(view_manager_.get(),
671 CreateNodeId(client_.id(), 1), 656 CreateNodeId(client_.id(), 1),
672 CreateNodeId(client_.id(), 11), 657 CreateNodeId(client_.id(), 11),
673 2)); 658 2));
674 ASSERT_TRUE(AddNode(view_manager_.get(), 659 ASSERT_TRUE(AddNode(view_manager_.get(),
675 CreateNodeId(client_.id(), 2), 660 CreateNodeId(client_.id(), 2),
676 CreateNodeId(client_.id(), 21), 661 CreateNodeId(client_.id(), 21),
677 3)); 662 3));
678 } 663 }
679 664
680 EstablishSecondConnection(); 665 EstablishSecondConnection();
681 666
682 // Remove 11. 667 // Remove 11.
683 { 668 {
684 AllocationScope scope;
685 ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(), 669 ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(),
686 CreateNodeId(client_.id(), 11), 670 CreateNodeId(client_.id(), 11),
687 4)); 671 4));
688 ASSERT_TRUE(client_.GetAndClearChanges().empty()); 672 ASSERT_TRUE(client_.GetAndClearChanges().empty());
689 673
690 client2_.DoRunLoopUntilChangesCount(1); 674 client2_.DoRunLoopUntilChangesCount(1);
691 Changes changes(client2_.GetAndClearChanges()); 675 Changes changes(client2_.GetAndClearChanges());
692 ASSERT_EQ(1u, changes.size()); 676 ASSERT_EQ(1u, changes.size());
693 EXPECT_EQ( 677 EXPECT_EQ(
694 "HierarchyChanged change_id=4 node=1,11 new_parent=null old_parent=1,1", 678 "HierarchyChanged change_id=4 node=1,11 new_parent=null old_parent=1,1",
695 changes[0]); 679 changes[0]);
696 EXPECT_TRUE(client2_.hierarchy_changed_nodes().empty()); 680 EXPECT_TRUE(client2_.hierarchy_changed_nodes().empty());
697 } 681 }
698 682
699 // Add 11 to 21. As client2 knows about 11 it should receive the new 683 // Add 11 to 21. As client2 knows about 11 it should receive the new
700 // hierarchy. 684 // hierarchy.
701 { 685 {
702 AllocationScope scope;
703 ASSERT_TRUE(AddNode(view_manager_.get(), 686 ASSERT_TRUE(AddNode(view_manager_.get(),
704 CreateNodeId(client_.id(), 21), 687 CreateNodeId(client_.id(), 21),
705 CreateNodeId(client_.id(), 11), 688 CreateNodeId(client_.id(), 11),
706 5)); 689 5));
707 ASSERT_TRUE(client_.GetAndClearChanges().empty()); 690 ASSERT_TRUE(client_.GetAndClearChanges().empty());
708 691
709 client2_.DoRunLoopUntilChangesCount(1); 692 client2_.DoRunLoopUntilChangesCount(1);
710 Changes changes(client2_.GetAndClearChanges()); 693 Changes changes(client2_.GetAndClearChanges());
711 ASSERT_EQ(1u, changes.size()); 694 ASSERT_EQ(1u, changes.size());
712 EXPECT_EQ( 695 EXPECT_EQ(
713 "HierarchyChanged change_id=5 node=1,11 new_parent=1,21 " 696 "HierarchyChanged change_id=5 node=1,11 new_parent=1,21 "
714 "old_parent=null", changes[0]); 697 "old_parent=null", changes[0]);
715 const std::vector<TestNode>& nodes(client2_.hierarchy_changed_nodes()); 698 const std::vector<TestNode>& nodes(client2_.hierarchy_changed_nodes());
716 ASSERT_EQ(2u, nodes.size()); 699 ASSERT_EQ(2u, nodes.size());
717 EXPECT_EQ("node=1,2 parent=null view=null", nodes[0].ToString()); 700 EXPECT_EQ("node=1,2 parent=null view=null", nodes[0].ToString());
718 EXPECT_EQ("node=1,21 parent=1,2 view=null", nodes[1].ToString()); 701 EXPECT_EQ("node=1,21 parent=1,2 view=null", nodes[1].ToString());
719 } 702 }
720 } 703 }
721 704
722 // Verifies connection on told descendants of the root when connecting. 705 // Verifies connection on told descendants of the root when connecting.
723 TEST_F(ViewManagerConnectionTest, GetInitialNodesOnInit) { 706 TEST_F(ViewManagerConnectionTest, GetInitialNodesOnInit) {
724 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 21)); 707 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 21));
725 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 3)); 708 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 3));
726 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 709 EXPECT_TRUE(client_.GetAndClearChanges().empty());
727 710
728 // Make 3 a child of 21. 711 // Make 3 a child of 21.
729 { 712 {
730 AllocationScope scope;
731 ASSERT_TRUE(AddNode(view_manager_.get(), 713 ASSERT_TRUE(AddNode(view_manager_.get(),
732 CreateNodeId(client_.id(), 21), 714 CreateNodeId(client_.id(), 21),
733 CreateNodeId(client_.id(), 3), 715 CreateNodeId(client_.id(), 3),
734 1)); 716 1));
735 ASSERT_TRUE(client_.GetAndClearChanges().empty()); 717 ASSERT_TRUE(client_.GetAndClearChanges().empty());
736 } 718 }
737 719
738 // Make 21 a child of the root. 720 // Make 21 a child of the root.
739 { 721 {
740 AllocationScope scope;
741 ASSERT_TRUE(AddNode(view_manager_.get(), 722 ASSERT_TRUE(AddNode(view_manager_.get(),
742 CreateNodeId(0, 1), 723 CreateNodeId(0, 1),
743 CreateNodeId(client_.id(), 21), 724 CreateNodeId(client_.id(), 21),
744 2)); 725 2));
745 ASSERT_TRUE(client_.GetAndClearChanges().empty()); 726 ASSERT_TRUE(client_.GetAndClearChanges().empty());
746 } 727 }
747 728
748 EstablishSecondConnection(); 729 EstablishSecondConnection();
749 // Should get notification of children of the root. 730 // Should get notification of children of the root.
750 const std::vector<TestNode>& nodes(client2_.initial_nodes()); 731 const std::vector<TestNode>& nodes(client2_.initial_nodes());
751 ASSERT_EQ(3u, nodes.size()); 732 ASSERT_EQ(3u, nodes.size());
752 EXPECT_EQ("node=0,1 parent=null view=null", nodes[0].ToString()); 733 EXPECT_EQ("node=0,1 parent=null view=null", nodes[0].ToString());
753 EXPECT_EQ("node=1,21 parent=0,1 view=null", nodes[1].ToString()); 734 EXPECT_EQ("node=1,21 parent=0,1 view=null", nodes[1].ToString());
754 EXPECT_EQ("node=1,3 parent=1,21 view=null", nodes[2].ToString()); 735 EXPECT_EQ("node=1,3 parent=1,21 view=null", nodes[2].ToString());
755 } 736 }
756 737
757 // Verifies DeleteNode works. 738 // Verifies DeleteNode works.
758 TEST_F(ViewManagerConnectionTest, DeleteNode) { 739 TEST_F(ViewManagerConnectionTest, DeleteNode) {
759 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 740 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
760 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2)); 741 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 2));
761 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 742 EXPECT_TRUE(client_.GetAndClearChanges().empty());
762 743
763 EstablishSecondConnection(); 744 EstablishSecondConnection();
764 EXPECT_TRUE(client2_.GetAndClearChanges().empty()); 745 EXPECT_TRUE(client2_.GetAndClearChanges().empty());
765 746
766 // Make 2 a child of 1. 747 // Make 2 a child of 1.
767 { 748 {
768 AllocationScope scope;
769 ASSERT_TRUE(AddNode(view_manager_.get(), 749 ASSERT_TRUE(AddNode(view_manager_.get(),
770 CreateNodeId(client_.id(), 1), 750 CreateNodeId(client_.id(), 1),
771 CreateNodeId(client_.id(), 2), 751 CreateNodeId(client_.id(), 2),
772 1)); 752 1));
773 Changes changes(client_.GetAndClearChanges()); 753 Changes changes(client_.GetAndClearChanges());
774 ASSERT_TRUE(changes.empty()); 754 ASSERT_TRUE(changes.empty());
775 755
776 client2_.DoRunLoopUntilChangesCount(1); 756 client2_.DoRunLoopUntilChangesCount(1);
777 changes = client2_.GetAndClearChanges(); 757 changes = client2_.GetAndClearChanges();
778 ASSERT_EQ(1u, changes.size()); 758 ASSERT_EQ(1u, changes.size());
779 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]); 759 EXPECT_EQ("ServerChangeIdAdvanced 2", changes[0]);
780 } 760 }
781 761
782 // Add 1 to the root 762 // Add 1 to the root
783 { 763 {
784 AllocationScope scope;
785 ASSERT_TRUE(AddNode(view_manager_.get(), 764 ASSERT_TRUE(AddNode(view_manager_.get(),
786 CreateNodeId(0, 1), 765 CreateNodeId(0, 1),
787 CreateNodeId(client_.id(), 1), 766 CreateNodeId(client_.id(), 1),
788 2)); 767 2));
789 Changes changes(client_.GetAndClearChanges()); 768 Changes changes(client_.GetAndClearChanges());
790 ASSERT_TRUE(changes.empty()); 769 ASSERT_TRUE(changes.empty());
791 770
792 client2_.DoRunLoopUntilChangesCount(1); 771 client2_.DoRunLoopUntilChangesCount(1);
793 changes = client2_.GetAndClearChanges(); 772 changes = client2_.GetAndClearChanges();
794 ASSERT_EQ(1u, changes.size()); 773 ASSERT_EQ(1u, changes.size());
795 EXPECT_EQ( 774 EXPECT_EQ(
796 "HierarchyChanged change_id=2 node=1,1 new_parent=0,1 old_parent=null", 775 "HierarchyChanged change_id=2 node=1,1 new_parent=0,1 old_parent=null",
797 changes[0]); 776 changes[0]);
798 } 777 }
799 778
800 // Delete 1. 779 // Delete 1.
801 { 780 {
802 AllocationScope scope;
803 ASSERT_TRUE(DeleteNode(view_manager_.get(), CreateNodeId(client_.id(), 1))); 781 ASSERT_TRUE(DeleteNode(view_manager_.get(), CreateNodeId(client_.id(), 1)));
804 Changes changes(client_.GetAndClearChanges()); 782 Changes changes(client_.GetAndClearChanges());
805 ASSERT_TRUE(changes.empty()); 783 ASSERT_TRUE(changes.empty());
806 784
807 client2_.DoRunLoopUntilChangesCount(1); 785 client2_.DoRunLoopUntilChangesCount(1);
808 changes = client2_.GetAndClearChanges(); 786 changes = client2_.GetAndClearChanges();
809 ASSERT_EQ(1u, changes.size()); 787 ASSERT_EQ(1u, changes.size());
810 EXPECT_EQ("NodeDeleted change_id=3 node=1,1", changes[0]); 788 EXPECT_EQ("NodeDeleted change_id=3 node=1,1", changes[0]);
811 } 789 }
812 } 790 }
(...skipping 15 matching lines...) Expand all
828 // Verifies if a node was deleted and then reused that other clients are 806 // Verifies if a node was deleted and then reused that other clients are
829 // properly notified. 807 // properly notified.
830 TEST_F(ViewManagerConnectionTest, ReusedDeletedId) { 808 TEST_F(ViewManagerConnectionTest, ReusedDeletedId) {
831 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 809 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
832 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 810 EXPECT_TRUE(client_.GetAndClearChanges().empty());
833 811
834 EstablishSecondConnection(); 812 EstablishSecondConnection();
835 813
836 // Make 1 a child of the root. 814 // Make 1 a child of the root.
837 { 815 {
838 AllocationScope scope;
839 ASSERT_TRUE(AddNode(view_manager_.get(), 816 ASSERT_TRUE(AddNode(view_manager_.get(),
840 CreateNodeId(0, 1), 817 CreateNodeId(0, 1),
841 CreateNodeId(client_.id(), 1), 818 CreateNodeId(client_.id(), 1),
842 1)); 819 1));
843 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 820 EXPECT_TRUE(client_.GetAndClearChanges().empty());
844 821
845 client2_.DoRunLoopUntilChangesCount(1); 822 client2_.DoRunLoopUntilChangesCount(1);
846 Changes changes = client2_.GetAndClearChanges(); 823 Changes changes = client2_.GetAndClearChanges();
847 EXPECT_EQ( 824 EXPECT_EQ(
848 "HierarchyChanged change_id=1 node=1,1 new_parent=0,1 old_parent=null", 825 "HierarchyChanged change_id=1 node=1,1 new_parent=0,1 old_parent=null",
849 changes[0]); 826 changes[0]);
850 const std::vector<TestNode>& nodes(client2_.hierarchy_changed_nodes()); 827 const std::vector<TestNode>& nodes(client2_.hierarchy_changed_nodes());
851 ASSERT_EQ(1u, nodes.size()); 828 ASSERT_EQ(1u, nodes.size());
852 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[0].ToString()); 829 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[0].ToString());
853 } 830 }
854 831
855 // Delete 1. 832 // Delete 1.
856 { 833 {
857 AllocationScope scope;
858 ASSERT_TRUE(DeleteNode(view_manager_.get(), CreateNodeId(client_.id(), 1))); 834 ASSERT_TRUE(DeleteNode(view_manager_.get(), CreateNodeId(client_.id(), 1)));
859 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 835 EXPECT_TRUE(client_.GetAndClearChanges().empty());
860 836
861 client2_.DoRunLoopUntilChangesCount(1); 837 client2_.DoRunLoopUntilChangesCount(1);
862 Changes changes = client2_.GetAndClearChanges(); 838 Changes changes = client2_.GetAndClearChanges();
863 ASSERT_EQ(1u, changes.size()); 839 ASSERT_EQ(1u, changes.size());
864 EXPECT_EQ("NodeDeleted change_id=2 node=1,1", changes[0]); 840 EXPECT_EQ("NodeDeleted change_id=2 node=1,1", changes[0]);
865 } 841 }
866 842
867 // Create 1 again, and add it back to the root. Should get the same 843 // Create 1 again, and add it back to the root. Should get the same
868 // notification. 844 // notification.
869 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1)); 845 ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
870 { 846 {
871 AllocationScope scope;
872 ASSERT_TRUE(AddNode(view_manager_.get(), 847 ASSERT_TRUE(AddNode(view_manager_.get(),
873 CreateNodeId(0, 1), 848 CreateNodeId(0, 1),
874 CreateNodeId(client_.id(), 1), 849 CreateNodeId(client_.id(), 1),
875 3)); 850 3));
876 EXPECT_TRUE(client_.GetAndClearChanges().empty()); 851 EXPECT_TRUE(client_.GetAndClearChanges().empty());
877 852
878 client2_.DoRunLoopUntilChangesCount(1); 853 client2_.DoRunLoopUntilChangesCount(1);
879 Changes changes = client2_.GetAndClearChanges(); 854 Changes changes = client2_.GetAndClearChanges();
880 EXPECT_EQ( 855 EXPECT_EQ(
881 "HierarchyChanged change_id=3 node=1,1 new_parent=0,1 old_parent=null", 856 "HierarchyChanged change_id=3 node=1,1 new_parent=0,1 old_parent=null",
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 4)); 1036 4));
1062 1037
1063 // Attach view to node 11 in the first connection. 1038 // Attach view to node 11 in the first connection.
1064 ASSERT_TRUE(CreateView(view_manager_.get(), 1, 51)); 1039 ASSERT_TRUE(CreateView(view_manager_.get(), 1, 51));
1065 ASSERT_TRUE(SetView(view_manager_.get(), 1040 ASSERT_TRUE(SetView(view_manager_.get(),
1066 CreateNodeId(client_.id(), 11), 1041 CreateNodeId(client_.id(), 11),
1067 CreateViewId(client_.id(), 51))); 1042 CreateViewId(client_.id(), 51)));
1068 1043
1069 // Verifies GetNodeTree() on the root. 1044 // Verifies GetNodeTree() on the root.
1070 { 1045 {
1071 AllocationScope scope;
1072 std::vector<TestNode> nodes; 1046 std::vector<TestNode> nodes;
1073 GetNodeTree(view_manager2_.get(), CreateNodeId(0, 1), &nodes); 1047 GetNodeTree(view_manager2_.get(), CreateNodeId(0, 1), &nodes);
1074 ASSERT_EQ(5u, nodes.size()); 1048 ASSERT_EQ(5u, nodes.size());
1075 EXPECT_EQ("node=0,1 parent=null view=null", nodes[0].ToString()); 1049 EXPECT_EQ("node=0,1 parent=null view=null", nodes[0].ToString());
1076 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[1].ToString()); 1050 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[1].ToString());
1077 EXPECT_EQ("node=1,11 parent=1,1 view=1,51", nodes[2].ToString()); 1051 EXPECT_EQ("node=1,11 parent=1,1 view=1,51", nodes[2].ToString());
1078 EXPECT_EQ("node=2,2 parent=0,1 view=null", nodes[3].ToString()); 1052 EXPECT_EQ("node=2,2 parent=0,1 view=null", nodes[3].ToString());
1079 EXPECT_EQ("node=2,3 parent=0,1 view=null", nodes[4].ToString()); 1053 EXPECT_EQ("node=2,3 parent=0,1 view=null", nodes[4].ToString());
1080 } 1054 }
1081 1055
1082 // Verifies GetNodeTree() on the node 1,1. 1056 // Verifies GetNodeTree() on the node 1,1.
1083 { 1057 {
1084 AllocationScope scope;
1085 std::vector<TestNode> nodes; 1058 std::vector<TestNode> nodes;
1086 GetNodeTree(view_manager2_.get(), CreateNodeId(1, 1), &nodes); 1059 GetNodeTree(view_manager2_.get(), CreateNodeId(1, 1), &nodes);
1087 ASSERT_EQ(2u, nodes.size()); 1060 ASSERT_EQ(2u, nodes.size());
1088 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[0].ToString()); 1061 EXPECT_EQ("node=1,1 parent=0,1 view=null", nodes[0].ToString());
1089 EXPECT_EQ("node=1,11 parent=1,1 view=1,51", nodes[1].ToString()); 1062 EXPECT_EQ("node=1,11 parent=1,1 view=1,51", nodes[1].ToString());
1090 } 1063 }
1091 } 1064 }
1092 1065
1093 } // namespace service 1066 } // namespace service
1094 } // namespace view_manager 1067 } // namespace view_manager
1095 } // namespace mojo 1068 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698