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 "mojo/services/public/cpp/view_manager/view_manager.h" | 5 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 base::RunLoop run_loop; | 35 base::RunLoop run_loop; |
36 current_run_loop = &run_loop; | 36 current_run_loop = &run_loop; |
37 current_run_loop->Run(); | 37 current_run_loop->Run(); |
38 current_run_loop = NULL; | 38 current_run_loop = NULL; |
39 } | 39 } |
40 | 40 |
41 void QuitRunLoop() { | 41 void QuitRunLoop() { |
42 current_run_loop->Quit(); | 42 current_run_loop->Quit(); |
43 } | 43 } |
44 | 44 |
45 void WaitForAllChangesToBeAcked(ViewManagerClientImpl* client) { | 45 void WaitForChangeToBeAcked(ViewManagerClientImpl* client) { |
46 client->set_changes_acked_callback(base::Bind(&QuitRunLoop)); | 46 client->set_change_acked_callback(base::Bind(&QuitRunLoop)); |
47 DoRunLoop(); | 47 DoRunLoop(); |
48 client->ClearChangesAckedCallback(); | 48 client->ClearChangeAckedCallback(); |
49 } | 49 } |
50 | 50 |
51 class ConnectServiceLoader : public ServiceLoader, | 51 class ConnectServiceLoader : public ServiceLoader, |
52 public ApplicationDelegate, | 52 public ApplicationDelegate, |
53 public ViewManagerDelegate { | 53 public ViewManagerDelegate { |
54 public: | 54 public: |
55 typedef base::Callback<void(ViewManager*, Node*)> LoadedCallback; | 55 typedef base::Callback<void(ViewManager*, Node*)> LoadedCallback; |
56 | 56 |
57 explicit ConnectServiceLoader(const LoadedCallback& callback) | 57 explicit ConnectServiceLoader(const LoadedCallback& callback) |
58 : callback_(callback), view_manager_client_factory_(this) {} | 58 : callback_(callback), view_manager_client_factory_(this) {} |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 // attached. | 643 // attached. |
644 TEST_F(ViewManagerTest, MapSubtreeOnAttach) { | 644 TEST_F(ViewManagerTest, MapSubtreeOnAttach) { |
645 Node* node = Node::Create(window_manager()); | 645 Node* node = Node::Create(window_manager()); |
646 window_manager()->GetRoots().front()->AddChild(node); | 646 window_manager()->GetRoots().front()->AddChild(node); |
647 ViewManager* embedded = Embed(window_manager(), node); | 647 ViewManager* embedded = Embed(window_manager(), node); |
648 | 648 |
649 // Create a subtree private to the window manager and make some changes to it. | 649 // Create a subtree private to the window manager and make some changes to it. |
650 Node* child1 = Node::Create(window_manager()); | 650 Node* child1 = Node::Create(window_manager()); |
651 Node* child11 = Node::Create(window_manager()); | 651 Node* child11 = Node::Create(window_manager()); |
652 child1->AddChild(child11); | 652 child1->AddChild(child11); |
| 653 WaitForChangeToBeAcked( |
| 654 static_cast<ViewManagerClientImpl*>(window_manager())); |
653 gfx::Rect child11_bounds(800, 600); | 655 gfx::Rect child11_bounds(800, 600); |
654 child11->SetBounds(child11_bounds); | 656 child11->SetBounds(child11_bounds); |
| 657 WaitForChangeToBeAcked( |
| 658 static_cast<ViewManagerClientImpl*>(window_manager())); |
655 View* view11 = View::Create(window_manager()); | 659 View* view11 = View::Create(window_manager()); |
656 child11->SetActiveView(view11); | 660 child11->SetActiveView(view11); |
657 WaitForAllChangesToBeAcked( | 661 WaitForChangeToBeAcked( |
658 static_cast<ViewManagerClientImpl*>(window_manager())); | 662 static_cast<ViewManagerClientImpl*>(window_manager())); |
659 | 663 |
660 // When added to the shared node, the entire hierarchy and all property | 664 // When added to the shared node, the entire hierarchy and all property |
661 // changes should become visible to the embedded app. | 665 // changes should become visible to the embedded app. |
662 node->AddChild(child1); | 666 node->AddChild(child1); |
663 WaitForTreeSizeToMatch(embedded->GetRoots().front(), 3); | 667 WaitForTreeSizeToMatch(embedded->GetRoots().front(), 3); |
664 | 668 |
665 Node* child11_in_embedded = embedded->GetNodeById(child11->id()); | 669 Node* child11_in_embedded = embedded->GetNodeById(child11->id()); |
666 View* view11_in_embedded = embedded->GetViewById(view11->id()); | 670 View* view11_in_embedded = embedded->GetViewById(view11->id()); |
667 EXPECT_TRUE(child11_in_embedded != NULL); | 671 EXPECT_TRUE(child11_in_embedded != NULL); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 // TODO(beng): tests for view event dispatcher. | 777 // TODO(beng): tests for view event dispatcher. |
774 // - verify that we see events for all views. | 778 // - verify that we see events for all views. |
775 | 779 |
776 // TODO(beng): tests for focus: | 780 // TODO(beng): tests for focus: |
777 // - focus between two nodes known to a connection | 781 // - focus between two nodes known to a connection |
778 // - focus between nodes unknown to one of the connections. | 782 // - focus between nodes unknown to one of the connections. |
779 // - focus between nodes unknown to either connection. | 783 // - focus between nodes unknown to either connection. |
780 | 784 |
781 } // namespace view_manager | 785 } // namespace view_manager |
782 } // namespace mojo | 786 } // namespace mojo |
OLD | NEW |