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

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

Issue 1351013002: Revert of Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/mus/client_connection.h" 9 #include "components/mus/client_connection.h"
10 #include "components/mus/connection_manager.h" 10 #include "components/mus/connection_manager.h"
(...skipping 15 matching lines...) Expand all
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;
33 using mojo::String; 33 using mojo::String;
34 using mojo::ViewDataPtr; 34 using mojo::ViewDataPtr;
35 35
36 namespace mus { 36 namespace view_manager {
37 namespace { 37 namespace {
38 38
39 // ----------------------------------------------------------------------------- 39 // -----------------------------------------------------------------------------
40 40
41 // ViewTreeClient implementation that logs all calls to a TestChangeTracker. 41 // ViewTreeClient implementation that logs all calls to a TestChangeTracker.
42 // TODO(sky): refactor so both this and ViewTreeAppTest share code. 42 // TODO(sky): refactor so both this and ViewTreeAppTest share code.
43 class TestViewTreeClient : public mojo::ViewTreeClient { 43 class TestViewTreeClient : public mojo::ViewTreeClient {
44 public: 44 public:
45 TestViewTreeClient() {} 45 TestViewTreeClient() {}
46 ~TestViewTreeClient() override {} 46 ~TestViewTreeClient() override {}
47 47
48 TestChangeTracker* tracker() { return &tracker_; } 48 TestChangeTracker* tracker() { return &tracker_; }
49 49
50 private: 50 private:
51 // ViewTreeClient: 51 // ViewTreeClient:
52 void OnEmbed(uint16_t connection_id, 52 void OnEmbed(uint16_t connection_id,
53 ViewDataPtr root, 53 ViewDataPtr root,
54 mojo::ViewTreePtr tree, 54 mojo::ViewTreePtr tree,
55 Id focused_view_id, 55 mojo::Id focused_view_id,
56 uint32_t access_policy) override { 56 uint32_t access_policy) override {
57 // TODO(sky): add test coverage of |focused_view_id|. 57 // TODO(sky): add test coverage of |focused_view_id|.
58 tracker_.OnEmbed(connection_id, root.Pass()); 58 tracker_.OnEmbed(connection_id, root.Pass());
59 } 59 }
60 void OnEmbeddedAppDisconnected(uint32_t view) override { 60 void OnEmbeddedAppDisconnected(uint32_t view) override {
61 tracker_.OnEmbeddedAppDisconnected(view); 61 tracker_.OnEmbeddedAppDisconnected(view);
62 } 62 }
63 void OnUnembed() override { tracker_.OnUnembed(); } 63 void OnUnembed() override { tracker_.OnUnembed(); }
64 void OnViewBoundsChanged(uint32_t view, 64 void OnViewBoundsChanged(uint32_t view,
65 mojo::RectPtr old_bounds, 65 mojo::RectPtr old_bounds,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 TestClientConnection* last_connection() { return last_connection_; } 142 TestClientConnection* last_connection() { return last_connection_; }
143 143
144 private: 144 private:
145 // ConnectionManagerDelegate: 145 // ConnectionManagerDelegate:
146 void OnNoMoreRootConnections() override {} 146 void OnNoMoreRootConnections() override {}
147 147
148 ClientConnection* CreateClientConnectionForEmbedAtView( 148 ClientConnection* CreateClientConnectionForEmbedAtView(
149 ConnectionManager* connection_manager, 149 ConnectionManager* connection_manager,
150 mojo::InterfaceRequest<mojo::ViewTree> service_request, 150 mojo::InterfaceRequest<mojo::ViewTree> service_request,
151 ConnectionSpecificId creator_id, 151 mojo::ConnectionSpecificId creator_id,
152 mojo::URLRequestPtr request, 152 mojo::URLRequestPtr request,
153 const ViewId& root_id, 153 const ViewId& root_id,
154 uint32_t policy_bitmask) override { 154 uint32_t policy_bitmask) override {
155 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( 155 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl(
156 connection_manager, creator_id, root_id, policy_bitmask)); 156 connection_manager, creator_id, root_id, policy_bitmask));
157 last_connection_ = new TestClientConnection(service.Pass()); 157 last_connection_ = new TestClientConnection(service.Pass());
158 return last_connection_; 158 return last_connection_;
159 } 159 }
160 ClientConnection* CreateClientConnectionForEmbedAtView( 160 ClientConnection* CreateClientConnectionForEmbedAtView(
161 ConnectionManager* connection_manager, 161 ConnectionManager* connection_manager,
162 mojo::InterfaceRequest<mojo::ViewTree> service_request, 162 mojo::InterfaceRequest<mojo::ViewTree> service_request,
163 ConnectionSpecificId creator_id, 163 mojo::ConnectionSpecificId creator_id,
164 const ViewId& root_id, 164 const ViewId& root_id,
165 uint32_t policy_bitmask, 165 uint32_t policy_bitmask,
166 mojo::ViewTreeClientPtr client) override { 166 mojo::ViewTreeClientPtr client) override {
167 // Used by ConnectionManager::AddRoot. 167 // Used by ConnectionManager::AddRoot.
168 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl( 168 scoped_ptr<ViewTreeImpl> service(new ViewTreeImpl(
169 connection_manager, creator_id, root_id, policy_bitmask)); 169 connection_manager, creator_id, root_id, policy_bitmask));
170 last_connection_ = new TestClientConnection(service.Pass()); 170 last_connection_ = new TestClientConnection(service.Pass());
171 return last_connection_; 171 return last_connection_;
172 } 172 }
173 173
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 }; 230 };
231 231
232 // Factory that dispenses TestDisplayManagers. 232 // Factory that dispenses TestDisplayManagers.
233 class TestDisplayManagerFactory : public DisplayManagerFactory { 233 class TestDisplayManagerFactory : public DisplayManagerFactory {
234 public: 234 public:
235 TestDisplayManagerFactory() {} 235 TestDisplayManagerFactory() {}
236 ~TestDisplayManagerFactory() {} 236 ~TestDisplayManagerFactory() {}
237 DisplayManager* CreateDisplayManager( 237 DisplayManager* CreateDisplayManager(
238 bool is_headless, 238 bool is_headless,
239 mojo::ApplicationImpl* app_impl, 239 mojo::ApplicationImpl* app_impl,
240 const scoped_refptr<GpuState>& gpu_state, 240 const scoped_refptr<gles2::GpuState>& gpu_state,
241 const scoped_refptr<SurfacesState>& surfaces_state) override { 241 const scoped_refptr<surfaces::SurfacesState>& surfaces_state) override {
242 return new TestDisplayManager(); 242 return new TestDisplayManager();
243 } 243 }
244 244
245 private: 245 private:
246 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerFactory); 246 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerFactory);
247 }; 247 };
248 248
249 mojo::EventPtr CreatePointerDownEvent(int x, int y) { 249 mojo::EventPtr CreatePointerDownEvent(int x, int y) {
250 mojo::EventPtr event(mojo::Event::New()); 250 mojo::EventPtr event(mojo::Event::New());
251 event->action = mojo::EVENT_TYPE_POINTER_DOWN; 251 event->action = mojo::EVENT_TYPE_POINTER_DOWN;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 TestViewTreeHostConnection* host_connection() { return host_connection_; } 295 TestViewTreeHostConnection* host_connection() { return host_connection_; }
296 DisplayManagerDelegate* display_manager_delegate() { 296 DisplayManagerDelegate* display_manager_delegate() {
297 return host_connection()->view_tree_host(); 297 return host_connection()->view_tree_host();
298 } 298 }
299 299
300 protected: 300 protected:
301 // testing::Test: 301 // testing::Test:
302 void SetUp() override { 302 void SetUp() override {
303 DisplayManager::set_factory_for_testing(&display_manager_factory_); 303 DisplayManager::set_factory_for_testing(&display_manager_factory_);
304 // TODO(fsamuel): This is probably broken. We need a root. 304 // TODO(fsamuel): This is probably broken. We need a root.
305 connection_manager_.reset( 305 connection_manager_.reset(new ConnectionManager(
306 new ConnectionManager(&delegate_, scoped_refptr<SurfacesState>())); 306 &delegate_, scoped_refptr<surfaces::SurfacesState>()));
307 ViewTreeHostImpl* host = new ViewTreeHostImpl( 307 ViewTreeHostImpl* host = new ViewTreeHostImpl(
308 mojo::ViewTreeHostClientPtr(), connection_manager_.get(), 308 mojo::ViewTreeHostClientPtr(), connection_manager_.get(),
309 true /* is_headless */, nullptr, scoped_refptr<GpuState>(), 309 true /* is_headless */, nullptr, scoped_refptr<gles2::GpuState>(),
310 scoped_refptr<SurfacesState>()); 310 scoped_refptr<surfaces::SurfacesState>());
311 // TODO(fsamuel): This is way too magical. We need to find a better way to 311 // TODO(fsamuel): This is way too magical. We need to find a better way to
312 // manage lifetime. 312 // manage lifetime.
313 host_connection_ = new TestViewTreeHostConnection( 313 host_connection_ = new TestViewTreeHostConnection(
314 make_scoped_ptr(host), connection_manager_.get()); 314 make_scoped_ptr(host), connection_manager_.get());
315 host->Init(host_connection_); 315 host->Init(host_connection_);
316 wm_client_ = delegate_.last_client(); 316 wm_client_ = delegate_.last_client();
317 } 317 }
318 318
319 private: 319 private:
320 // TestViewTreeClient that is used for the WM connection. 320 // TestViewTreeClient that is used for the WM connection.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size()); 440 ASSERT_EQ(1u, wm_client()->tracker()->changes()->size());
441 EXPECT_EQ("Focused id=2,1", 441 EXPECT_EQ("Focused id=2,1",
442 ChangesToDescription1(*wm_client()->tracker()->changes())[0]); 442 ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
443 ASSERT_EQ(2u, embed_connection->tracker()->changes()->size()); 443 ASSERT_EQ(2u, embed_connection->tracker()->changes()->size());
444 EXPECT_EQ("Focused id=2,1", 444 EXPECT_EQ("Focused id=2,1",
445 ChangesToDescription1(*embed_connection->tracker()->changes())[0]); 445 ChangesToDescription1(*embed_connection->tracker()->changes())[0]);
446 EXPECT_EQ("InputEvent view=2,1 event_action=4", 446 EXPECT_EQ("InputEvent view=2,1 event_action=4",
447 ChangesToDescription1(*embed_connection->tracker()->changes())[1]); 447 ChangesToDescription1(*embed_connection->tracker()->changes())[1]);
448 } 448 }
449 449
450 } // namespace mus 450 } // 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