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

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

Issue 489493004: Update view manager to support content handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah to the blizzah Created 6 years, 3 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/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 } 1146 }
1147 1147
1148 TEST_F(ViewManagerTest, ConnectTwice) { 1148 TEST_F(ViewManagerTest, ConnectTwice) {
1149 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1149 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1150 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); 1150 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2)));
1151 1151
1152 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1152 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1153 1153
1154 // Try to connect again to 1,1, this should fail as already connected to that 1154 // Try to connect again to 1,1, this should fail as already connected to that
1155 // root. 1155 // root.
1156 ASSERT_FALSE(connection_->Embed(BuildNodeId(1, 1), kTestServiceURL)); 1156 ASSERT_TRUE(connection_->Embed(BuildNodeId(1, 1), kTestServiceURL));
1157 1157
1158 // Connecting to 1,2 should succeed and end up in connection2. 1158 // Connecting to 1,2 should succeed and end up in connection2.
1159 { 1159 {
1160 ASSERT_TRUE(connection_->Embed(BuildNodeId(1, 2), kTestServiceURL)); 1160 ASSERT_TRUE(connection_->Embed(BuildNodeId(1, 2), kTestServiceURL));
1161 connection2_->DoRunLoopUntilChangesCount(1); 1161 connection2_->DoRunLoopUntilChangesCount(1);
1162 const Changes changes(ChangesToDescription1(connection2_->changes())); 1162 const Changes changes(ChangesToDescription1(connection2_->changes()));
1163 ASSERT_EQ(1u, changes.size()); 1163 ASSERT_EQ(1u, changes.size());
1164 EXPECT_EQ("OnEmbed creator=mojo:test_url", changes[0]); 1164 EXPECT_EQ("NodeDeleted node=1,1", changes[0]);
1165 EXPECT_EQ("[node=1,2 parent=null]",
1166 ChangeNodeDescription(connection2_->changes()));
1167 } 1165 }
1168 } 1166 }
1169 1167
1170 TEST_F(ViewManagerTest, OnNodeInput) { 1168 TEST_F(ViewManagerTest, OnNodeInput) {
1171 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); 1169 ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1)));
1172 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1170 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1173 1171
1174 // Dispatch an event to the node and verify its received. 1172 // Dispatch an event to the node and verify its received.
1175 { 1173 {
1176 EventPtr event(Event::New()); 1174 EventPtr event(Event::New());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1221
1224 // Connection 1 should have been told about the add (it owns the node). 1222 // Connection 1 should have been told about the add (it owns the node).
1225 { 1223 {
1226 connection_->DoRunLoopUntilChangesCount(1); 1224 connection_->DoRunLoopUntilChangesCount(1);
1227 const Changes changes(ChangesToDescription1(connection_->changes())); 1225 const Changes changes(ChangesToDescription1(connection_->changes()));
1228 ASSERT_EQ(1u, changes.size()); 1226 ASSERT_EQ(1u, changes.size());
1229 EXPECT_EQ("HierarchyChanged node=3,1 new_parent=1,1 old_parent=null", 1227 EXPECT_EQ("HierarchyChanged node=3,1 new_parent=1,1 old_parent=null",
1230 changes[0]); 1228 changes[0]);
1231 } 1229 }
1232 1230
1233 // Embed 1,1 back in connection 2. 1231 // Embed 1,1 again.
1234 { 1232 {
1235 // 2 should be told about the new embed. 1233 // We should get a new connection for the new embedding.
1236 ASSERT_TRUE(connection_->Embed(BuildNodeId(1, 1), kTestServiceURL)); 1234 ASSERT_TRUE(connection_->Embed(BuildNodeId(1, 1), kTestServiceURL));
1237 connection2_->DoRunLoopUntilChangesCount(1); 1235 ViewManagerProxy* connection4 = ViewManagerProxy::WaitForInstance();
1238 const std::vector<Change>& changes(connection2_->changes()); 1236 connection4->DoRunLoopUntilChangesCount(1);
1237 const std::vector<Change>& changes(connection4->changes());
1239 ASSERT_EQ(1u, changes.size()); 1238 ASSERT_EQ(1u, changes.size());
1240 EXPECT_EQ("OnEmbed creator=mojo:test_url", 1239 EXPECT_EQ("OnEmbed creator=mojo:test_url",
1241 ChangesToDescription1(changes)[0]); 1240 ChangesToDescription1(changes)[0]);
1242 EXPECT_EQ("[node=1,1 parent=null]", 1241 EXPECT_EQ("[node=1,1 parent=null]",
1243 ChangeNodeDescription(changes)); 1242 ChangeNodeDescription(changes));
1244 1243
1245 // And 3 should get a delete. 1244 // And 3 should get a delete.
1246 connection3_->DoRunLoopUntilChangesCount(1); 1245 connection3_->DoRunLoopUntilChangesCount(1);
1247 ASSERT_EQ(1u, connection3_->changes().size()); 1246 ASSERT_EQ(1u, connection3_->changes().size());
1248 EXPECT_EQ("NodeDeleted node=1,1", 1247 EXPECT_EQ("NodeDeleted node=1,1",
(...skipping 27 matching lines...) Expand all
1276 1275
1277 // TODO(sky): add coverage of test that destroys connections and ensures other 1276 // TODO(sky): add coverage of test that destroys connections and ensures other
1278 // connections get deletion notification. 1277 // connections get deletion notification.
1279 1278
1280 // TODO(sky): need to better track changes to initial connection. For example, 1279 // TODO(sky): need to better track changes to initial connection. For example,
1281 // that SetBounsdNodes/AddNode and the like don't result in messages to the 1280 // that SetBounsdNodes/AddNode and the like don't result in messages to the
1282 // originating connection. 1281 // originating connection.
1283 1282
1284 } // namespace service 1283 } // namespace service
1285 } // namespace mojo 1284 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/view_manager_service_impl.cc ('k') | mojo/shell/dynamic_application_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698