| 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 // ViewManagerClient: | 321 // ViewMangerClient: |
| 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 } | |
| 369 virtual void DispatchOnViewInputEvent(Id view_id, | 366 virtual void DispatchOnViewInputEvent(Id view_id, |
| 370 mojo::EventPtr event) OVERRIDE { | 367 mojo::EventPtr event) OVERRIDE { |
| 371 } | 368 } |
| 372 | 369 |
| 373 private: | 370 private: |
| 374 TestChangeTracker tracker_; | 371 TestChangeTracker tracker_; |
| 375 ViewManagerProxy connection_; | 372 ViewManagerProxy connection_; |
| 376 | 373 |
| 377 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); | 374 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); |
| 378 }; | 375 }; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 shell::ShellTestHelper test_helper_; | 510 shell::ShellTestHelper test_helper_; |
| 514 | 511 |
| 515 ViewManagerInitServicePtr view_manager_init_; | 512 ViewManagerInitServicePtr view_manager_init_; |
| 516 | 513 |
| 517 ViewManagerProxy* connection_; | 514 ViewManagerProxy* connection_; |
| 518 ViewManagerProxy* connection2_; | 515 ViewManagerProxy* connection2_; |
| 519 | 516 |
| 520 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest); | 517 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest); |
| 521 }; | 518 }; |
| 522 | 519 |
| 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 | |
| 529 // Verifies client gets a valid id. | 520 // Verifies client gets a valid id. |
| 530 TEST_F(ViewManagerTest, ValidId) { | 521 TEST_F(ViewManagerTest, ValidId) { |
| 531 // TODO(beng): this should really have the URL of the application that | 522 // TODO(beng): this should really have the URL of the application that |
| 532 // connected to ViewManagerInit. | 523 // connected to ViewManagerInit. |
| 533 EXPECT_EQ("OnConnectionEstablished creator=", | 524 EXPECT_EQ("OnConnectionEstablished creator=", |
| 534 ChangesToDescription1(connection_->changes())[0]); | 525 ChangesToDescription1(connection_->changes())[0]); |
| 535 | 526 |
| 536 // All these tests assume 1 for the client id. The only real assertion here is | 527 // All these tests assume 1 for the client id. The only real assertion here is |
| 537 // the client id is not zero, but adding this as rest of code here assumes 1. | 528 // the client id is not zero, but adding this as rest of code here assumes 1. |
| 538 EXPECT_EQ(1, connection_->changes()[0].connection_id); | 529 EXPECT_EQ(1, connection_->changes()[0].connection_id); |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 // originating connection. | 1385 // originating connection. |
| 1395 | 1386 |
| 1396 // TODO(beng): Add tests for focus: | 1387 // TODO(beng): Add tests for focus: |
| 1397 // - focus between two nodes known to a connection | 1388 // - focus between two nodes known to a connection |
| 1398 // - focus between nodes unknown to one of the connections. | 1389 // - focus between nodes unknown to one of the connections. |
| 1399 // - focus between nodes unknown to either connection. | 1390 // - focus between nodes unknown to either connection. |
| 1400 | 1391 |
| 1401 } // namespace service | 1392 } // namespace service |
| 1402 } // namespace view_manager | 1393 } // namespace view_manager |
| 1403 } // namespace mojo | 1394 } // namespace mojo |
| OLD | NEW |