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

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

Issue 323413003: Makes the view manager notify the client of new roots correctly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « mojo/services/view_manager/view_manager_connection.cc ('k') | 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/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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 1193
1194 // Should get node 1 if asked for. 1194 // Should get node 1 if asked for.
1195 connection2_->GetNodeTree(BuildNodeId(1, 1), &nodes); 1195 connection2_->GetNodeTree(BuildNodeId(1, 1), &nodes);
1196 ASSERT_EQ(1u, nodes.size()); 1196 ASSERT_EQ(1u, nodes.size());
1197 EXPECT_EQ("node=1,1 parent=null view=null", nodes[0].ToString()); 1197 EXPECT_EQ("node=1,1 parent=null view=null", nodes[0].ToString());
1198 } 1198 }
1199 1199
1200 TEST_F(ViewManagerConnectionTest, ConnectTwice) { 1200 TEST_F(ViewManagerConnectionTest, ConnectTwice) {
1201 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1201 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1202 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1202 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1203
1204 ASSERT_TRUE(connection_->AddNode(BuildNodeId(1, 1), BuildNodeId(1, 2), 1));
1205
1203 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1206 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1204 1207
1205 // Try to connect again to 1,1, this should fail as already connected to that 1208 // Try to connect again to 1,1, this should fail as already connected to that
1206 // root. 1209 // root.
1207 { 1210 {
1208 std::vector<Id> node_ids; 1211 std::vector<Id> node_ids;
1209 node_ids.push_back(BuildNodeId(1, 1)); 1212 node_ids.push_back(BuildNodeId(1, 1));
1210 ASSERT_FALSE(connection_->Embed(node_ids)); 1213 ASSERT_FALSE(connection_->Embed(node_ids));
1211 } 1214 }
1212 1215
1213 // Connecting to 1,2 should succeed and end up in connection2. 1216 // Connecting to 1,2 should succeed and end up in connection2.
1214 { 1217 {
1215 std::vector<Id> node_ids; 1218 std::vector<Id> node_ids;
1216 node_ids.push_back(BuildNodeId(1, 2)); 1219 node_ids.push_back(BuildNodeId(1, 2));
1217 ASSERT_TRUE(connection_->Embed(node_ids)); 1220 ASSERT_TRUE(connection_->Embed(node_ids));
1218 connection2_->DoRunLoopUntilChangesCount(1); 1221 connection2_->DoRunLoopUntilChangesCount(1);
1219 const Changes changes(ChangesToDescription1(connection2_->changes())); 1222 const Changes changes(ChangesToDescription1(connection2_->changes()));
1220 ASSERT_EQ(1u, changes.size()); 1223 ASSERT_EQ(1u, changes.size());
1221 EXPECT_EQ("OnRootsAdded", changes[0]); 1224 EXPECT_EQ("OnRootsAdded", changes[0]);
1222 EXPECT_EQ("[node=1,2 parent=null view=null]", 1225 EXPECT_EQ("[node=1,2 parent=1,1 view=null]",
1223 ChangeNodeDescription(connection2_->changes())); 1226 ChangeNodeDescription(connection2_->changes()));
1224 } 1227 }
1225 } 1228 }
1226 1229
1227 // TODO(sky): add coverage of test that destroys connections and ensures other 1230 // TODO(sky): add coverage of test that destroys connections and ensures other
1228 // connections get deletion notification (or advanced server id). 1231 // connections get deletion notification (or advanced server id).
1229 1232
1230 // TODO(sky): need to better track changes to initial connection. For example, 1233 // TODO(sky): need to better track changes to initial connection. For example,
1231 // that SetBounsdNodes/AddNode and the like don't result in messages to the 1234 // that SetBounsdNodes/AddNode and the like don't result in messages to the
1232 // originating connection. 1235 // originating connection.
1233 1236
1234 } // namespace service 1237 } // namespace service
1235 } // namespace view_manager 1238 } // namespace view_manager
1236 } // namespace mojo 1239 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698