OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mandoline/tab/frame.h" | 5 #include "mandoline/tab/frame.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
13 #include "components/view_manager/public/cpp/lib/view_manager_client_impl.h" | 13 #include "components/view_manager/public/cpp/view_manager.h" |
14 #include "components/view_manager/public/cpp/view_manager_delegate.h" | 14 #include "components/view_manager/public/cpp/view_manager_delegate.h" |
15 #include "components/view_manager/public/cpp/view_manager_init.h" | 15 #include "components/view_manager/public/cpp/view_manager_init.h" |
16 #include "components/view_manager/public/cpp/view_observer.h" | 16 #include "components/view_manager/public/cpp/view_observer.h" |
17 #include "mandoline/tab/frame.h" | 17 #include "mandoline/tab/frame.h" |
18 #include "mandoline/tab/frame_tree.h" | 18 #include "mandoline/tab/frame_tree.h" |
19 #include "mandoline/tab/frame_tree_delegate.h" | 19 #include "mandoline/tab/frame_tree_delegate.h" |
20 #include "mandoline/tab/frame_user_data.h" | 20 #include "mandoline/tab/frame_user_data.h" |
21 #include "mandoline/tab/test_frame_tree_delegate.h" | 21 #include "mandoline/tab/test_frame_tree_delegate.h" |
22 #include "mojo/application/public/cpp/application_connection.h" | 22 #include "mojo/application/public/cpp/application_connection.h" |
23 #include "mojo/application/public/cpp/application_delegate.h" | 23 #include "mojo/application/public/cpp/application_delegate.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 void QuitRunLoop() { | 59 void QuitRunLoop() { |
60 current_run_loop->Quit(); | 60 current_run_loop->Quit(); |
61 current_run_loop = nullptr; | 61 current_run_loop = nullptr; |
62 } | 62 } |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 class FrameTest : public mojo::test::ApplicationTestBase, | 66 class FrameTest : public mojo::test::ApplicationTestBase, |
67 public mojo::ApplicationDelegate, | 67 public mojo::ApplicationDelegate, |
68 public mojo::ViewManagerDelegate, | 68 public mojo::ViewManagerDelegate, |
69 public mojo::InterfaceFactory<mojo::ViewManagerClient> { | 69 public mojo::InterfaceFactory<mojo::ViewTreeClient> { |
70 public: | 70 public: |
71 FrameTest() : most_recent_view_manager_(nullptr), window_manager_(nullptr) {} | 71 FrameTest() : most_recent_view_tree_(nullptr), window_manager_(nullptr) {} |
72 | 72 |
73 ViewManager* most_recent_view_manager() { return most_recent_view_manager_; } | 73 ViewManager* most_recent_view_tree() { return most_recent_view_tree_; } |
74 | 74 |
75 // ApplicationDelegate implementation. | 75 // ApplicationDelegate implementation. |
76 bool ConfigureIncomingConnection( | 76 bool ConfigureIncomingConnection( |
77 mojo::ApplicationConnection* connection) override { | 77 mojo::ApplicationConnection* connection) override { |
78 connection->AddService<mojo::ViewManagerClient>(this); | 78 connection->AddService<mojo::ViewTreeClient>(this); |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
82 ViewManager* window_manager() { return window_manager_; } | 82 ViewManager* window_manager() { return window_manager_; } |
83 | 83 |
84 // ApplicationTestBase: | 84 // ApplicationTestBase: |
85 ApplicationDelegate* GetApplicationDelegate() override { return this; } | 85 ApplicationDelegate* GetApplicationDelegate() override { return this; } |
86 | 86 |
87 // Overridden from ViewManagerDelegate: | 87 // Overridden from ViewManagerDelegate: |
88 void OnEmbed(View* root) override { | 88 void OnEmbed(View* root) override { |
89 most_recent_view_manager_ = root->view_manager(); | 89 most_recent_view_tree_ = root->view_manager(); |
90 QuitRunLoop(); | 90 QuitRunLoop(); |
91 } | 91 } |
92 void OnViewManagerDestroyed(ViewManager* view_manager) override {} | 92 void OnViewManagerDestroyed(ViewManager* view_manager) override {} |
93 | 93 |
94 private: | 94 private: |
95 // Overridden from testing::Test: | 95 // Overridden from testing::Test: |
96 void SetUp() override { | 96 void SetUp() override { |
97 ApplicationTestBase::SetUp(); | 97 ApplicationTestBase::SetUp(); |
98 | 98 |
99 view_manager_init_.reset( | 99 view_manager_init_.reset( |
100 new mojo::ViewManagerInit(application_impl(), this, nullptr)); | 100 new mojo::ViewManagerInit(application_impl(), this, nullptr)); |
101 ASSERT_TRUE(DoRunLoopWithTimeout()); | 101 ASSERT_TRUE(DoRunLoopWithTimeout()); |
102 std::swap(window_manager_, most_recent_view_manager_); | 102 std::swap(window_manager_, most_recent_view_tree_); |
103 } | 103 } |
104 | 104 |
105 // Overridden from testing::Test: | 105 // Overridden from testing::Test: |
106 void TearDown() override { | 106 void TearDown() override { |
107 view_manager_init_.reset(); // Uses application_impl() from base class. | 107 view_manager_init_.reset(); // Uses application_impl() from base class. |
108 ApplicationTestBase::TearDown(); | 108 ApplicationTestBase::TearDown(); |
109 } | 109 } |
110 | 110 |
111 // Overridden from mojo::InterfaceFactory<mojo::ViewManagerClient>: | 111 // Overridden from mojo::InterfaceFactory<mojo::ViewTreeClient>: |
112 void Create( | 112 void Create( |
113 mojo::ApplicationConnection* connection, | 113 mojo::ApplicationConnection* connection, |
114 mojo::InterfaceRequest<mojo::ViewManagerClient> request) override { | 114 mojo::InterfaceRequest<mojo::ViewTreeClient> request) override { |
115 mojo::ViewManager::Create(this, request.Pass()); | 115 mojo::ViewManager::Create(this, request.Pass()); |
116 } | 116 } |
117 | 117 |
118 scoped_ptr<mojo::ViewManagerInit> view_manager_init_; | 118 scoped_ptr<mojo::ViewManagerInit> view_manager_init_; |
119 | 119 |
120 // Used to receive the most recent view manager loaded by an embed action. | 120 // Used to receive the most recent view manager loaded by an embed action. |
121 ViewManager* most_recent_view_manager_; | 121 ViewManager* most_recent_view_tree_; |
122 // The View Manager connection held by the window manager (app running at the | 122 // The View Manager connection held by the window manager (app running at the |
123 // root view). | 123 // root view). |
124 ViewManager* window_manager_; | 124 ViewManager* window_manager_; |
125 | 125 |
126 MOJO_DISALLOW_COPY_AND_ASSIGN(FrameTest); | 126 MOJO_DISALLOW_COPY_AND_ASSIGN(FrameTest); |
127 }; | 127 }; |
128 | 128 |
129 class TestFrameTreeClient : public FrameTreeClient { | 129 class TestFrameTreeClient : public FrameTreeClient { |
130 public: | 130 public: |
131 TestFrameTreeClient() : connect_count_(0) {} | 131 TestFrameTreeClient() : connect_count_(0) {} |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 EXPECT_EQ(tree.root()->view()->id(), frames_in_child[0]->frame_id); | 206 EXPECT_EQ(tree.root()->view()->id(), frames_in_child[0]->frame_id); |
207 EXPECT_EQ(0u, frames_in_child[0]->parent_id); | 207 EXPECT_EQ(0u, frames_in_child[0]->parent_id); |
208 EXPECT_EQ(child_frame->view()->id(), frames_in_child[1]->frame_id); | 208 EXPECT_EQ(child_frame->view()->id(), frames_in_child[1]->frame_id); |
209 EXPECT_EQ(tree.root()->view()->id(), frames_in_child[1]->parent_id); | 209 EXPECT_EQ(tree.root()->view()->id(), frames_in_child[1]->parent_id); |
210 | 210 |
211 // We should have gotten notification of the add. | 211 // We should have gotten notification of the add. |
212 EXPECT_EQ(1u, root_client.adds().size()); | 212 EXPECT_EQ(1u, root_client.adds().size()); |
213 } | 213 } |
214 | 214 |
215 } // namespace mandoline | 215 } // namespace mandoline |
OLD | NEW |