| Index: mojo/services/view_manager/view_manager_connection_unittest.cc
|
| diff --git a/mojo/services/view_manager/view_manager_connection_unittest.cc b/mojo/services/view_manager/view_manager_connection_unittest.cc
|
| index 63c20ac308f2b83dbb2fc23ae215efa953c33af4..49bba90c3dfca679aa74b0334477c1145e9b8178 100644
|
| --- a/mojo/services/view_manager/view_manager_connection_unittest.cc
|
| +++ b/mojo/services/view_manager/view_manager_connection_unittest.cc
|
| @@ -12,7 +12,6 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "mojo/common/common_type_converters.h"
|
| #include "mojo/geometry/geometry_type_converters.h"
|
| -#include "mojo/public/cpp/bindings/allocation_scope.h"
|
| #include "mojo/public/cpp/environment/environment.h"
|
| #include "mojo/public/cpp/shell/connect.h"
|
| #include "mojo/services/public/cpp/view_manager/util.h"
|
| @@ -23,21 +22,6 @@
|
| #include "ui/gfx/geometry/rect.h"
|
|
|
| namespace mojo {
|
| -
|
| -// TODO(sky): remove this when Darin is done with cleanup.
|
| -template <typename T>
|
| -class MOJO_COMMON_EXPORT TypeConverter<T, T> {
|
| - public:
|
| - static T ConvertFrom(T input, Buffer* buf) {
|
| - return input;
|
| - }
|
| - static T ConvertTo(T input) {
|
| - return input;
|
| - }
|
| -
|
| - MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
|
| -};
|
| -
|
| namespace view_manager {
|
| namespace service {
|
|
|
| @@ -63,12 +47,12 @@ std::string NodeIdToString(TransportNodeId id) {
|
| }
|
|
|
| // Converts |rect| into a string.
|
| -std::string RectToString(const Rect& rect) {
|
| +std::string RectToString(const RectPtr& rect) {
|
| return base::StringPrintf("%d,%d %dx%d",
|
| - rect.position().x(),
|
| - rect.position().y(),
|
| - rect.size().width(),
|
| - rect.size().height());
|
| + rect->position->x,
|
| + rect->position->y,
|
| + rect->size->width,
|
| + rect->size->height);
|
| }
|
|
|
| // Boolean callback. Sets |result_cache| to the value of |result| and quits
|
| @@ -91,13 +75,13 @@ struct TestNode {
|
| TransportNodeId view_id;
|
| };
|
|
|
| -void INodesToTestNodes(const mojo::Array<INode>& data,
|
| +void INodesToTestNodes(const mojo::Array<INodePtr>& data,
|
| std::vector<TestNode>* test_nodes) {
|
| for (size_t i = 0; i < data.size(); ++i) {
|
| TestNode node;
|
| - node.parent_id = data[i].parent_id();
|
| - node.node_id = data[i].node_id();
|
| - node.view_id = data[i].view_id();
|
| + node.parent_id = data[i]->parent_id;
|
| + node.node_id = data[i]->node_id;
|
| + node.view_id = data[i]->view_id;
|
| test_nodes->push_back(node);
|
| }
|
| }
|
| @@ -105,7 +89,7 @@ void INodesToTestNodes(const mojo::Array<INode>& data,
|
| // Callback that results in a vector of INodes. The INodes are converted to
|
| // TestNodes.
|
| void INodesCallback(std::vector<TestNode>* test_nodes,
|
| - const mojo::Array<INode>& data) {
|
| + mojo::Array<INodePtr> data) {
|
| INodesToTestNodes(data, test_nodes);
|
| current_run_loop->Quit();
|
| }
|
| @@ -154,7 +138,7 @@ bool SetNodeBounds(IViewManager* view_manager,
|
| TransportNodeId node_id,
|
| const gfx::Rect& bounds) {
|
| bool result = false;
|
| - view_manager->SetNodeBounds(node_id, bounds,
|
| + view_manager->SetNodeBounds(node_id, Rect::From(bounds),
|
| base::Bind(&BooleanCallback, &result));
|
| DoRunLoop();
|
| return result;
|
| @@ -275,7 +259,7 @@ class ViewManagerClientImpl : public IViewManagerClient {
|
| virtual void OnViewManagerConnectionEstablished(
|
| TransportConnectionId connection_id,
|
| TransportChangeId next_server_change_id,
|
| - const mojo::Array<INode>& nodes) OVERRIDE {
|
| + mojo::Array<INodePtr> nodes) OVERRIDE {
|
| id_ = connection_id;
|
| next_server_change_id_ = next_server_change_id;
|
| initial_nodes_.clear();
|
| @@ -292,8 +276,8 @@ class ViewManagerClientImpl : public IViewManagerClient {
|
| QuitIfNecessary();
|
| }
|
| virtual void OnNodeBoundsChanged(TransportNodeId node_id,
|
| - const Rect& old_bounds,
|
| - const Rect& new_bounds) OVERRIDE {
|
| + RectPtr old_bounds,
|
| + RectPtr new_bounds) OVERRIDE {
|
| changes_.push_back(
|
| base::StringPrintf(
|
| "BoundsChanged node=%s old_bounds=%s new_bounds=%s",
|
| @@ -307,7 +291,7 @@ class ViewManagerClientImpl : public IViewManagerClient {
|
| TransportNodeId new_parent,
|
| TransportNodeId old_parent,
|
| TransportChangeId server_change_id,
|
| - const mojo::Array<INode>& nodes) OVERRIDE {
|
| + mojo::Array<INodePtr> nodes) OVERRIDE {
|
| changes_.push_back(
|
| base::StringPrintf(
|
| "HierarchyChanged change_id=%d node=%s new_parent=%s old_parent=%s",
|
| @@ -397,7 +381,6 @@ class ViewManagerConnectionTest : public testing::Test {
|
| EstablishSecondConnection();
|
| client2_.ClearId();
|
|
|
| - AllocationScope scope;
|
| std::vector<uint32_t> roots;
|
| roots.push_back(root_id);
|
| ASSERT_TRUE(SetRoots(view_manager_.get(), 2, roots));
|
| @@ -472,7 +455,6 @@ TEST_F(ViewManagerConnectionTest, AddRemoveNotify) {
|
|
|
| // Make 2 a child of 1.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 1),
|
| CreateNodeId(client_.id(), 2),
|
| @@ -488,7 +470,6 @@ TEST_F(ViewManagerConnectionTest, AddRemoveNotify) {
|
|
|
| // Remove 2 from its parent.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(),
|
| CreateNodeId(client_.id(), 2),
|
| 2));
|
| @@ -514,7 +495,6 @@ TEST_F(ViewManagerConnectionTest, AddNodeWithNoChange) {
|
|
|
| // Make 2 a child of 1.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 1),
|
| CreateNodeId(client_.id(), 2),
|
| @@ -530,7 +510,6 @@ TEST_F(ViewManagerConnectionTest, AddNodeWithNoChange) {
|
|
|
| // Try again, this should fail.
|
| {
|
| - AllocationScope scope;
|
| EXPECT_FALSE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 1),
|
| CreateNodeId(client_.id(), 2),
|
| @@ -552,7 +531,6 @@ TEST_F(ViewManagerConnectionTest, AddAncestorFails) {
|
|
|
| // Make 2 a child of 1.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 1),
|
| CreateNodeId(client_.id(), 2),
|
| @@ -568,7 +546,6 @@ TEST_F(ViewManagerConnectionTest, AddAncestorFails) {
|
|
|
| // Try to make 1 a child of 2, this should fail since 1 is an ancestor of 2.
|
| {
|
| - AllocationScope scope;
|
| EXPECT_FALSE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 2),
|
| CreateNodeId(client_.id(), 1),
|
| @@ -586,7 +563,6 @@ TEST_F(ViewManagerConnectionTest, AddWithInvalidServerId) {
|
|
|
| // Make 2 a child of 1. Supply an invalid change id, which should fail.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_FALSE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 1),
|
| CreateNodeId(client_.id(), 2),
|
| @@ -607,7 +583,6 @@ TEST_F(ViewManagerConnectionTest, AddToRoot) {
|
|
|
| // Make 3 a child of 21.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 21),
|
| CreateNodeId(client_.id(), 3),
|
| @@ -623,7 +598,6 @@ TEST_F(ViewManagerConnectionTest, AddToRoot) {
|
|
|
| // Make 21 a child of the root.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(0, 1),
|
| CreateNodeId(client_.id(), 21),
|
| @@ -648,7 +622,6 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedNodes) {
|
|
|
| // Make 11 a child of 1.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 1),
|
| CreateNodeId(client_.id(), 11),
|
| @@ -660,7 +633,6 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedNodes) {
|
|
|
| // Make 1 a child of the root.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(0, 1),
|
| CreateNodeId(client_.id(), 1),
|
| @@ -683,7 +655,6 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedNodes) {
|
|
|
| // Remove 1 from the root.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(),
|
| CreateNodeId(client_.id(), 1),
|
| 3));
|
| @@ -700,7 +671,6 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedNodes) {
|
| // Create another node, 111, parent it to 11.
|
| ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 111));
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 11),
|
| CreateNodeId(client_.id(), 111),
|
| @@ -748,7 +718,6 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedAddingKnownToUnknown) {
|
|
|
| // Set up the hierarchy.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(0, 1),
|
| CreateNodeId(client_.id(), 1),
|
| @@ -767,7 +736,6 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedAddingKnownToUnknown) {
|
|
|
| // Remove 11.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(RemoveNodeFromParent(view_manager_.get(),
|
| CreateNodeId(client_.id(), 11),
|
| 4));
|
| @@ -785,7 +753,6 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedAddingKnownToUnknown) {
|
| // Add 11 to 21. As client2 knows about 11 it should receive the new
|
| // hierarchy.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 21),
|
| CreateNodeId(client_.id(), 11),
|
| @@ -813,7 +780,6 @@ TEST_F(ViewManagerConnectionTest, GetInitialNodesOnInit) {
|
|
|
| // Make 3 a child of 21.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 21),
|
| CreateNodeId(client_.id(), 3),
|
| @@ -823,7 +789,6 @@ TEST_F(ViewManagerConnectionTest, GetInitialNodesOnInit) {
|
|
|
| // Make 21 a child of the root.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(0, 1),
|
| CreateNodeId(client_.id(), 21),
|
| @@ -851,7 +816,6 @@ TEST_F(ViewManagerConnectionTest, DeleteNode) {
|
|
|
| // Make 2 a child of 1.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(client_.id(), 1),
|
| CreateNodeId(client_.id(), 2),
|
| @@ -867,7 +831,6 @@ TEST_F(ViewManagerConnectionTest, DeleteNode) {
|
|
|
| // Add 1 to the root
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(0, 1),
|
| CreateNodeId(client_.id(), 1),
|
| @@ -885,7 +848,6 @@ TEST_F(ViewManagerConnectionTest, DeleteNode) {
|
|
|
| // Delete 1.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(DeleteNode(view_manager_.get(), CreateNodeId(client_.id(), 1)));
|
| Changes changes(client_.GetAndClearChanges());
|
| ASSERT_TRUE(changes.empty());
|
| @@ -921,7 +883,6 @@ TEST_F(ViewManagerConnectionTest, ReusedDeletedId) {
|
|
|
| // Make 1 a child of the root.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(0, 1),
|
| CreateNodeId(client_.id(), 1),
|
| @@ -940,7 +901,6 @@ TEST_F(ViewManagerConnectionTest, ReusedDeletedId) {
|
|
|
| // Delete 1.
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(DeleteNode(view_manager_.get(), CreateNodeId(client_.id(), 1)));
|
| EXPECT_TRUE(client_.GetAndClearChanges().empty());
|
|
|
| @@ -954,7 +914,6 @@ TEST_F(ViewManagerConnectionTest, ReusedDeletedId) {
|
| // notification.
|
| ASSERT_TRUE(CreateNode(view_manager_.get(), 1, 1));
|
| {
|
| - AllocationScope scope;
|
| ASSERT_TRUE(AddNode(view_manager_.get(),
|
| CreateNodeId(0, 1),
|
| CreateNodeId(client_.id(), 1),
|
| @@ -1156,7 +1115,6 @@ TEST_F(ViewManagerConnectionTest, GetNodeTree) {
|
|
|
| // Verifies GetNodeTree() on the root.
|
| {
|
| - AllocationScope scope;
|
| std::vector<TestNode> nodes;
|
| GetNodeTree(view_manager2_.get(), CreateNodeId(0, 1), &nodes);
|
| ASSERT_EQ(5u, nodes.size());
|
| @@ -1169,7 +1127,6 @@ TEST_F(ViewManagerConnectionTest, GetNodeTree) {
|
|
|
| // Verifies GetNodeTree() on the node 1,1.
|
| {
|
| - AllocationScope scope;
|
| std::vector<TestNode> nodes;
|
| GetNodeTree(view_manager2_.get(), CreateNodeId(1, 1), &nodes);
|
| ASSERT_EQ(2u, nodes.size());
|
| @@ -1186,7 +1143,6 @@ TEST_F(ViewManagerConnectionTest, SetNodeBounds) {
|
| 1));
|
| EstablishSecondConnection();
|
|
|
| - AllocationScope scope;
|
| ASSERT_TRUE(SetNodeBounds(view_manager_.get(),
|
| CreateNodeId(1, 1),
|
| gfx::Rect(0, 0, 100, 100)));
|
| @@ -1221,7 +1177,6 @@ TEST_F(ViewManagerConnectionTest, SetRoots) {
|
| EstablishSecondConnection();
|
| client2_.ClearId();
|
| {
|
| - AllocationScope scope;
|
| std::vector<uint32_t> roots;
|
| roots.push_back(CreateNodeId(1, 1));
|
| roots.push_back(CreateNodeId(1, 3));
|
| @@ -1362,7 +1317,6 @@ TEST_F(ViewManagerConnectionTest, CantRemoveNodesInOtherRoots) {
|
|
|
| // Verify nothing was actually removed.
|
| {
|
| - AllocationScope scope;
|
| std::vector<TestNode> nodes;
|
| GetNodeTree(view_manager_.get(), CreateNodeId(0, 1), &nodes);
|
| ASSERT_EQ(3u, nodes.size());
|
| @@ -1423,7 +1377,6 @@ TEST_F(ViewManagerConnectionTest, CantGetNodeTreeOfOtherRoots) {
|
| ASSERT_NO_FATAL_FAILURE(
|
| EstablishSecondConnectionWithRoot(CreateNodeId(1, 1)));
|
|
|
| - AllocationScope scope;
|
| std::vector<TestNode> nodes;
|
|
|
| // Should get nothing for the root.
|
|
|