Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: components/mus/view_tree_unittest.cc

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/view_tree_impl.cc ('k') | components/mus/window_manager_access_policy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "components/view_manager/client_connection.h" 9 #include "components/mus/client_connection.h"
10 #include "components/view_manager/connection_manager.h" 10 #include "components/mus/connection_manager.h"
11 #include "components/view_manager/connection_manager_delegate.h" 11 #include "components/mus/connection_manager_delegate.h"
12 #include "components/view_manager/display_manager.h" 12 #include "components/mus/display_manager.h"
13 #include "components/view_manager/display_manager_factory.h" 13 #include "components/mus/display_manager_factory.h"
14 #include "components/view_manager/ids.h" 14 #include "components/mus/ids.h"
15 #include "components/view_manager/public/cpp/types.h" 15 #include "components/mus/public/cpp/types.h"
16 #include "components/view_manager/public/cpp/util.h" 16 #include "components/mus/public/cpp/util.h"
17 #include "components/view_manager/public/interfaces/view_tree.mojom.h" 17 #include "components/mus/public/interfaces/view_tree.mojom.h"
18 #include "components/view_manager/server_view.h" 18 #include "components/mus/server_view.h"
19 #include "components/view_manager/surfaces/surfaces_state.h" 19 #include "components/mus/surfaces/surfaces_state.h"
20 #include "components/view_manager/test_change_tracker.h" 20 #include "components/mus/test_change_tracker.h"
21 #include "components/view_manager/view_tree_host_connection.h" 21 #include "components/mus/view_tree_host_connection.h"
22 #include "components/view_manager/view_tree_impl.h" 22 #include "components/mus/view_tree_impl.h"
23 #include "mojo/application/public/interfaces/service_provider.mojom.h" 23 #include "mojo/application/public/interfaces/service_provider.mojom.h"
24 #include "mojo/converters/geometry/geometry_type_converters.h" 24 #include "mojo/converters/geometry/geometry_type_converters.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
27 27
28 using mojo::Array; 28 using mojo::Array;
29 using mojo::ERROR_CODE_NONE; 29 using mojo::ERROR_CODE_NONE;
30 using mojo::InterfaceRequest; 30 using mojo::InterfaceRequest;
31 using mojo::ServiceProvider; 31 using mojo::ServiceProvider;
32 using mojo::ServiceProviderPtr; 32 using mojo::ServiceProviderPtr;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 TestClientConnection* last_connection_; 172 TestClientConnection* last_connection_;
173 173
174 DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate); 174 DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate);
175 }; 175 };
176 176
177 // ----------------------------------------------------------------------------- 177 // -----------------------------------------------------------------------------
178 178
179 class TestViewTreeHostConnection : public ViewTreeHostConnection { 179 class TestViewTreeHostConnection : public ViewTreeHostConnection {
180 public: 180 public:
181 TestViewTreeHostConnection(scoped_ptr<ViewTreeHostImpl> host_impl, 181 TestViewTreeHostConnection(scoped_ptr<ViewTreeHostImpl> host_impl,
182 ConnectionManager* manager) 182 ConnectionManager* manager)
183 : ViewTreeHostConnection(host_impl.Pass(), manager) {} 183 : ViewTreeHostConnection(host_impl.Pass(), manager) {}
184 ~TestViewTreeHostConnection() override {} 184 ~TestViewTreeHostConnection() override {}
185 185
186 private: 186 private:
187 // ViewTreeHostDelegate: 187 // ViewTreeHostDelegate:
188 void OnDisplayInitialized() override { 188 void OnDisplayInitialized() override {
189 connection_manager()->AddHost(this); 189 connection_manager()->AddHost(this);
190 set_view_tree(connection_manager()->EmbedAtView( 190 set_view_tree(connection_manager()->EmbedAtView(
191 kInvalidConnectionId, 191 kInvalidConnectionId, view_tree_host()->root_view()->id(),
192 view_tree_host()->root_view()->id(),
193 mojo::ViewTreeClientPtr())); 192 mojo::ViewTreeClientPtr()));
194 } 193 }
195 DISALLOW_COPY_AND_ASSIGN(TestViewTreeHostConnection); 194 DISALLOW_COPY_AND_ASSIGN(TestViewTreeHostConnection);
196 }; 195 };
197 196
198 // ----------------------------------------------------------------------------- 197 // -----------------------------------------------------------------------------
199 // Empty implementation of DisplayManager. 198 // Empty implementation of DisplayManager.
200 class TestDisplayManager : public DisplayManager { 199 class TestDisplayManager : public DisplayManager {
201 public: 200 public:
202 TestDisplayManager() {} 201 TestDisplayManager() {}
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 TestViewTreeHostConnection* host_connection() { return host_connection_; } 293 TestViewTreeHostConnection* host_connection() { return host_connection_; }
295 DisplayManagerDelegate* display_manager_delegate() { 294 DisplayManagerDelegate* display_manager_delegate() {
296 return host_connection()->view_tree_host(); 295 return host_connection()->view_tree_host();
297 } 296 }
298 297
299 protected: 298 protected:
300 // testing::Test: 299 // testing::Test:
301 void SetUp() override { 300 void SetUp() override {
302 DisplayManager::set_factory_for_testing(&display_manager_factory_); 301 DisplayManager::set_factory_for_testing(&display_manager_factory_);
303 // TODO(fsamuel): This is probably broken. We need a root. 302 // TODO(fsamuel): This is probably broken. We need a root.
304 connection_manager_.reset( 303 connection_manager_.reset(new ConnectionManager(
305 new ConnectionManager(&delegate_, 304 &delegate_, scoped_refptr<surfaces::SurfacesState>()));
306 scoped_refptr<surfaces::SurfacesState>()));
307 ViewTreeHostImpl* host = new ViewTreeHostImpl( 305 ViewTreeHostImpl* host = new ViewTreeHostImpl(
308 mojo::ViewTreeHostClientPtr(), 306 mojo::ViewTreeHostClientPtr(), connection_manager_.get(),
309 connection_manager_.get(), true /* is_headless */, nullptr, 307 true /* is_headless */, nullptr, scoped_refptr<gles2::GpuState>(),
310 scoped_refptr<gles2::GpuState>(),
311 scoped_refptr<surfaces::SurfacesState>()); 308 scoped_refptr<surfaces::SurfacesState>());
312 // TODO(fsamuel): This is way too magical. We need to find a better way to 309 // TODO(fsamuel): This is way too magical. We need to find a better way to
313 // manage lifetime. 310 // manage lifetime.
314 host_connection_ = new TestViewTreeHostConnection( 311 host_connection_ = new TestViewTreeHostConnection(
315 make_scoped_ptr(host), connection_manager_.get()); 312 make_scoped_ptr(host), connection_manager_.get());
316 host->Init(host_connection_); 313 host->Init(host_connection_);
317 wm_client_ = delegate_.last_client(); 314 wm_client_ = delegate_.last_client();
318 } 315 }
319 316
320 private: 317 private:
321 // TestViewTreeClient that is used for the WM connection. 318 // TestViewTreeClient that is used for the WM connection.
322 TestViewTreeClient* wm_client_; 319 TestViewTreeClient* wm_client_;
323 TestDisplayManagerFactory display_manager_factory_; 320 TestDisplayManagerFactory display_manager_factory_;
324 TestConnectionManagerDelegate delegate_; 321 TestConnectionManagerDelegate delegate_;
325 TestViewTreeHostConnection* host_connection_; 322 TestViewTreeHostConnection* host_connection_;
326 scoped_ptr<ConnectionManager> connection_manager_; 323 scoped_ptr<ConnectionManager> connection_manager_;
327 base::MessageLoop message_loop_; 324 base::MessageLoop message_loop_;
328 325
329 DISALLOW_COPY_AND_ASSIGN(ViewTreeTest); 326 DISALLOW_COPY_AND_ASSIGN(ViewTreeTest);
330 }; 327 };
331 328
332 // Verifies focus correctly changes on pointer events. 329 // Verifies focus correctly changes on pointer events.
333 TEST_F(ViewTreeTest, FocusOnPointer) { 330 TEST_F(ViewTreeTest, FocusOnPointer) {
334 const ViewId embed_view_id(wm_connection()->id(), 1); 331 const ViewId embed_view_id(wm_connection()->id(), 1);
335 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id)); 332 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id));
336 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true)); 333 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true));
337 EXPECT_TRUE( 334 EXPECT_TRUE(
338 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id)); 335 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id));
339 host_connection()->view_tree_host()->root_view()-> 336 host_connection()->view_tree_host()->root_view()->SetBounds(
340 SetBounds(gfx::Rect(0, 0, 100, 100)); 337 gfx::Rect(0, 0, 100, 100));
341 mojo::URLRequestPtr request(mojo::URLRequest::New()); 338 mojo::URLRequestPtr request(mojo::URLRequest::New());
342 wm_connection()->Embed(embed_view_id, request.Pass()); 339 wm_connection()->Embed(embed_view_id, request.Pass());
343 ViewTreeImpl* connection1 = 340 ViewTreeImpl* connection1 =
344 connection_manager()->GetConnectionWithRoot(embed_view_id); 341 connection_manager()->GetConnectionWithRoot(embed_view_id);
345 ASSERT_TRUE(connection1 != nullptr); 342 ASSERT_TRUE(connection1 != nullptr);
346 ASSERT_NE(connection1, wm_connection()); 343 ASSERT_NE(connection1, wm_connection());
347 344
348 connection_manager() 345 connection_manager()
349 ->GetView(embed_view_id) 346 ->GetView(embed_view_id)
350 ->SetBounds(gfx::Rect(0, 0, 50, 50)); 347 ->SetBounds(gfx::Rect(0, 0, 50, 50));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 EXPECT_EQ("Focused id=2,1", 439 EXPECT_EQ("Focused id=2,1",
443 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); 440 ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
444 ASSERT_EQ(2u, embed_connection->tracker()->changes()->size()); 441 ASSERT_EQ(2u, embed_connection->tracker()->changes()->size());
445 EXPECT_EQ("Focused id=2,1", 442 EXPECT_EQ("Focused id=2,1",
446 ChangesToDescription1(*embed_connection->tracker()->changes())[0]); 443 ChangesToDescription1(*embed_connection->tracker()->changes())[0]);
447 EXPECT_EQ("InputEvent view=2,1 event_action=4", 444 EXPECT_EQ("InputEvent view=2,1 event_action=4",
448 ChangesToDescription1(*embed_connection->tracker()->changes())[1]); 445 ChangesToDescription1(*embed_connection->tracker()->changes())[1]);
449 } 446 }
450 447
451 } // namespace view_manager 448 } // namespace view_manager
OLDNEW
« no previous file with comments | « components/mus/view_tree_impl.cc ('k') | components/mus/window_manager_access_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698