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/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 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 } | 1153 } |
1154 | 1154 |
1155 TEST_F(ViewManagerTest, ConnectTwice) { | 1155 TEST_F(ViewManagerTest, ConnectTwice) { |
1156 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 1))); | 1156 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 1))); |
1157 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 2))); | 1157 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 2))); |
1158 | 1158 |
1159 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); | 1159 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); |
1160 | 1160 |
1161 // Try to connect again to 1,1, this should fail as already connected to that | 1161 // Try to connect again to 1,1, this should fail as already connected to that |
1162 // root. | 1162 // root. |
1163 ASSERT_FALSE(connection_->Embed(BuildViewId(1, 1), kTestServiceURL)); | 1163 ASSERT_TRUE(connection_->Embed(BuildViewId(1, 1), kTestServiceURL)); |
1164 | 1164 |
1165 // Connecting to 1,2 should succeed and end up in connection2. | 1165 // Connecting to 1,2 should succeed and end up in connection2. |
1166 { | 1166 { |
1167 ASSERT_TRUE(connection_->Embed(BuildViewId(1, 2), kTestServiceURL)); | 1167 ASSERT_TRUE(connection_->Embed(BuildViewId(1, 2), kTestServiceURL)); |
1168 connection2_->DoRunLoopUntilChangesCount(1); | 1168 connection2_->DoRunLoopUntilChangesCount(1); |
1169 const Changes changes(ChangesToDescription1(connection2_->changes())); | 1169 const Changes changes(ChangesToDescription1(connection2_->changes())); |
1170 ASSERT_EQ(1u, changes.size()); | 1170 ASSERT_EQ(1u, changes.size()); |
1171 EXPECT_EQ("OnEmbed creator=mojo:test_url", changes[0]); | 1171 EXPECT_EQ("NodeDeleted node=1,1", changes[0]); |
1172 EXPECT_EQ("[view=1,2 parent=null]", | |
1173 ChangeViewDescription(connection2_->changes())); | |
1174 } | 1172 } |
1175 } | 1173 } |
1176 | 1174 |
1177 TEST_F(ViewManagerTest, OnViewInput) { | 1175 TEST_F(ViewManagerTest, OnViewInput) { |
1178 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 1))); | 1176 ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 1))); |
1179 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); | 1177 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); |
1180 | 1178 |
1181 // Dispatch an event to the view and verify its received. | 1179 // Dispatch an event to the view and verify its received. |
1182 { | 1180 { |
1183 EventPtr event(Event::New()); | 1181 EventPtr event(Event::New()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 | 1227 |
1230 // Connection 1 should have been told about the add (it owns the view). | 1228 // Connection 1 should have been told about the add (it owns the view). |
1231 { | 1229 { |
1232 connection_->DoRunLoopUntilChangesCount(1); | 1230 connection_->DoRunLoopUntilChangesCount(1); |
1233 const Changes changes(ChangesToDescription1(connection_->changes())); | 1231 const Changes changes(ChangesToDescription1(connection_->changes())); |
1234 ASSERT_EQ(1u, changes.size()); | 1232 ASSERT_EQ(1u, changes.size()); |
1235 EXPECT_EQ("HierarchyChanged view=3,1 new_parent=1,1 old_parent=null", | 1233 EXPECT_EQ("HierarchyChanged view=3,1 new_parent=1,1 old_parent=null", |
1236 changes[0]); | 1234 changes[0]); |
1237 } | 1235 } |
1238 | 1236 |
1239 // Embed 1,1 back in connection 2. | 1237 // Embed 1,1 again. |
1240 { | 1238 { |
1241 // 2 should be told about the new embed. | 1239 // We should get a new connection for the new embedding. |
1242 ASSERT_TRUE(connection_->Embed(BuildViewId(1, 1), kTestServiceURL)); | 1240 ASSERT_TRUE(connection_->Embed(BuildViewId(1, 1), kTestServiceURL)); |
1243 connection2_->DoRunLoopUntilChangesCount(1); | 1241 ViewManagerProxy* connection4 = ViewManagerProxy::WaitForInstance(); |
1244 const std::vector<Change>& changes(connection2_->changes()); | 1242 connection4->DoRunLoopUntilChangesCount(1); |
| 1243 const std::vector<Change>& changes(connection4->changes()); |
1245 ASSERT_EQ(1u, changes.size()); | 1244 ASSERT_EQ(1u, changes.size()); |
1246 EXPECT_EQ("OnEmbed creator=mojo:test_url", | 1245 EXPECT_EQ("OnEmbed creator=mojo:test_url", |
1247 ChangesToDescription1(changes)[0]); | 1246 ChangesToDescription1(changes)[0]); |
1248 EXPECT_EQ("[view=1,1 parent=null]", ChangeViewDescription(changes)); | 1247 EXPECT_EQ("[view=1,1 parent=null]", ChangeViewDescription(changes)); |
1249 | 1248 |
1250 // And 3 should get a delete. | 1249 // And 3 should get a delete. |
1251 connection3_->DoRunLoopUntilChangesCount(1); | 1250 connection3_->DoRunLoopUntilChangesCount(1); |
1252 ASSERT_EQ(1u, connection3_->changes().size()); | 1251 ASSERT_EQ(1u, connection3_->changes().size()); |
1253 EXPECT_EQ("ViewDeleted view=1,1", | 1252 EXPECT_EQ("ViewDeleted view=1,1", |
1254 ChangesToDescription1(connection3_->changes())[0]); | 1253 ChangesToDescription1(connection3_->changes())[0]); |
(...skipping 26 matching lines...) Expand all Loading... |
1281 | 1280 |
1282 // TODO(sky): add coverage of test that destroys connections and ensures other | 1281 // TODO(sky): add coverage of test that destroys connections and ensures other |
1283 // connections get deletion notification. | 1282 // connections get deletion notification. |
1284 | 1283 |
1285 // TODO(sky): need to better track changes to initial connection. For example, | 1284 // TODO(sky): need to better track changes to initial connection. For example, |
1286 // that SetBounsdViews/AddView and the like don't result in messages to the | 1285 // that SetBounsdViews/AddView and the like don't result in messages to the |
1287 // originating connection. | 1286 // originating connection. |
1288 | 1287 |
1289 } // namespace service | 1288 } // namespace service |
1290 } // namespace mojo | 1289 } // namespace mojo |
OLD | NEW |