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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 connection_(&tracker_) { | 311 connection_(&tracker_) { |
312 tracker_.set_delegate(&connection_); | 312 tracker_.set_delegate(&connection_); |
313 } | 313 } |
314 | 314 |
315 // InterfaceImp: | 315 // InterfaceImp: |
316 virtual void OnConnectionEstablished() OVERRIDE { | 316 virtual void OnConnectionEstablished() OVERRIDE { |
317 connection_.set_router(internal_state()->router()); | 317 connection_.set_router(internal_state()->router()); |
318 connection_.set_view_manager(client()); | 318 connection_.set_view_manager(client()); |
319 } | 319 } |
320 | 320 |
321 // ViewMangerClient: | 321 // ViewManagerClient: |
322 virtual void OnViewManagerConnectionEstablished( | 322 virtual void OnViewManagerConnectionEstablished( |
323 ConnectionSpecificId connection_id, | 323 ConnectionSpecificId connection_id, |
324 const String& creator_url, | 324 const String& creator_url, |
325 Array<NodeDataPtr> nodes) OVERRIDE { | 325 Array<NodeDataPtr> nodes) OVERRIDE { |
326 tracker_.OnViewManagerConnectionEstablished( | 326 tracker_.OnViewManagerConnectionEstablished( |
327 connection_id, creator_url, nodes.Pass()); | 327 connection_id, creator_url, nodes.Pass()); |
328 } | 328 } |
329 virtual void OnRootAdded(Array<NodeDataPtr> nodes) OVERRIDE { | 329 virtual void OnRootAdded(Array<NodeDataPtr> nodes) OVERRIDE { |
330 tracker_.OnRootAdded(nodes.Pass()); | 330 tracker_.OnRootAdded(nodes.Pass()); |
331 } | 331 } |
(...skipping 24 matching lines...) Expand all Loading... |
356 Id old_view_id) OVERRIDE { | 356 Id old_view_id) OVERRIDE { |
357 tracker_.OnNodeViewReplaced(node, new_view_id, old_view_id); | 357 tracker_.OnNodeViewReplaced(node, new_view_id, old_view_id); |
358 } | 358 } |
359 virtual void OnViewInputEvent(Id view_id, | 359 virtual void OnViewInputEvent(Id view_id, |
360 EventPtr event, | 360 EventPtr event, |
361 const Callback<void()>& callback) OVERRIDE { | 361 const Callback<void()>& callback) OVERRIDE { |
362 tracker_.OnViewInputEvent(view_id, event.Pass()); | 362 tracker_.OnViewInputEvent(view_id, event.Pass()); |
363 } | 363 } |
364 virtual void OnFocusChanged(Id gained_focus_id, | 364 virtual void OnFocusChanged(Id gained_focus_id, |
365 Id lost_focus_id) OVERRIDE {} | 365 Id lost_focus_id) OVERRIDE {} |
| 366 virtual void EmbedRoot(const String& url) OVERRIDE { |
| 367 tracker_.OnEmbedRoot(url); |
| 368 } |
366 virtual void DispatchOnViewInputEvent(Id view_id, | 369 virtual void DispatchOnViewInputEvent(Id view_id, |
367 mojo::EventPtr event) OVERRIDE { | 370 mojo::EventPtr event) OVERRIDE { |
368 } | 371 } |
369 | 372 |
370 private: | 373 private: |
371 TestChangeTracker tracker_; | 374 TestChangeTracker tracker_; |
372 ViewManagerProxy connection_; | 375 ViewManagerProxy connection_; |
373 | 376 |
374 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); | 377 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); |
375 }; | 378 }; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 shell::ShellTestHelper test_helper_; | 513 shell::ShellTestHelper test_helper_; |
511 | 514 |
512 ViewManagerInitServicePtr view_manager_init_; | 515 ViewManagerInitServicePtr view_manager_init_; |
513 | 516 |
514 ViewManagerProxy* connection_; | 517 ViewManagerProxy* connection_; |
515 ViewManagerProxy* connection2_; | 518 ViewManagerProxy* connection2_; |
516 | 519 |
517 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest); | 520 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest); |
518 }; | 521 }; |
519 | 522 |
| 523 TEST_F(ViewManagerTest, SecondEmbedRoot) { |
| 524 ASSERT_TRUE(EmbedRoot(view_manager_init_.get(), kTestServiceURL)); |
| 525 connection_->DoRunLoopUntilChangesCount(1); |
| 526 EXPECT_EQ(kTestServiceURL, connection_->changes()[0].embed_url); |
| 527 } |
| 528 |
520 // Verifies client gets a valid id. | 529 // Verifies client gets a valid id. |
521 TEST_F(ViewManagerTest, ValidId) { | 530 TEST_F(ViewManagerTest, ValidId) { |
522 // TODO(beng): this should really have the URL of the application that | 531 // TODO(beng): this should really have the URL of the application that |
523 // connected to ViewManagerInit. | 532 // connected to ViewManagerInit. |
524 EXPECT_EQ("OnConnectionEstablished creator=", | 533 EXPECT_EQ("OnConnectionEstablished creator=", |
525 ChangesToDescription1(connection_->changes())[0]); | 534 ChangesToDescription1(connection_->changes())[0]); |
526 | 535 |
527 // All these tests assume 1 for the client id. The only real assertion here is | 536 // All these tests assume 1 for the client id. The only real assertion here is |
528 // the client id is not zero, but adding this as rest of code here assumes 1. | 537 // the client id is not zero, but adding this as rest of code here assumes 1. |
529 EXPECT_EQ(1, connection_->changes()[0].connection_id); | 538 EXPECT_EQ(1, connection_->changes()[0].connection_id); |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 // originating connection. | 1394 // originating connection. |
1386 | 1395 |
1387 // TODO(beng): Add tests for focus: | 1396 // TODO(beng): Add tests for focus: |
1388 // - focus between two nodes known to a connection | 1397 // - focus between two nodes known to a connection |
1389 // - focus between nodes unknown to one of the connections. | 1398 // - focus between nodes unknown to one of the connections. |
1390 // - focus between nodes unknown to either connection. | 1399 // - focus between nodes unknown to either connection. |
1391 | 1400 |
1392 } // namespace service | 1401 } // namespace service |
1393 } // namespace view_manager | 1402 } // namespace view_manager |
1394 } // namespace mojo | 1403 } // namespace mojo |
OLD | NEW |