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
3 // found in the LICENSE file.
8 #include "base/message_loop/message_loop.h"
9 #include "components/view_manager/client_connection.h"
10 #include "components/view_manager/connection_manager.h"
11 #include "components/view_manager/connection_manager_delegate.h"
12 #include "components/view_manager/display_manager.h"
13 #include "components/view_manager/display_manager_factory.h"
14 #include "components/view_manager/gles2/gpu_state.h"
15 #include "components/view_manager/ids.h"
16 #include "components/view_manager/public/cpp/types.h"
17 #include "components/view_manager/public/cpp/util.h"
18 #include "components/view_manager/public/interfaces/view_manager.mojom.h"
19 #include "components/view_manager/server_view.h"
20 #include "components/view_manager/test_change_tracker.h"
21 #include "components/view_manager/view_manager_service_impl.h"
22 #include "mojo/application/public/interfaces/service_provider.mojom.h"
23 #include "mojo/converters/geometry/geometry_type_converters.h"
24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/gfx/geometry/rect.h"
28 using mojo::ERROR_CODE_NONE
;
29 using mojo::InterfaceRequest
;
30 using mojo::ServiceProvider
;
31 using mojo::ServiceProviderPtr
;
33 using mojo::ViewDataPtr
;
35 namespace view_manager
{
38 // -----------------------------------------------------------------------------
40 // ViewManagerClient implementation that logs all calls to a TestChangeTracker.
41 // TODO(sky): refactor so both this and ViewManagerServiceAppTest share code.
42 class TestViewManagerClient
: public mojo::ViewManagerClient
{
44 TestViewManagerClient() {}
45 ~TestViewManagerClient() override
{}
47 TestChangeTracker
* tracker() { return &tracker_
; }
51 void OnEmbed(uint16_t connection_id
,
53 mojo::ViewManagerServicePtr view_manager_service
,
54 mojo::Id focused_view_id
) override
{
55 // TODO(sky): add test coverage of |focused_view_id|.
56 tracker_
.OnEmbed(connection_id
, root
.Pass());
58 void OnEmbedForDescendant(
60 mojo::URLRequestPtr request
,
61 const OnEmbedForDescendantCallback
& callback
) override
{}
62 void OnEmbeddedAppDisconnected(uint32_t view
) override
{
63 tracker_
.OnEmbeddedAppDisconnected(view
);
65 void OnViewBoundsChanged(uint32_t view
,
66 mojo::RectPtr old_bounds
,
67 mojo::RectPtr new_bounds
) override
{
68 tracker_
.OnViewBoundsChanged(view
, old_bounds
.Pass(), new_bounds
.Pass());
70 void OnViewViewportMetricsChanged(
71 mojo::ViewportMetricsPtr old_metrics
,
72 mojo::ViewportMetricsPtr new_metrics
) override
{
73 tracker_
.OnViewViewportMetricsChanged(old_metrics
.Pass(),
76 void OnViewHierarchyChanged(uint32_t view
,
79 Array
<ViewDataPtr
> views
) override
{
80 tracker_
.OnViewHierarchyChanged(view
, new_parent
, old_parent
, views
.Pass());
82 void OnViewReordered(uint32_t view_id
,
83 uint32_t relative_view_id
,
84 mojo::OrderDirection direction
) override
{
85 tracker_
.OnViewReordered(view_id
, relative_view_id
, direction
);
87 void OnViewDeleted(uint32_t view
) override
{ tracker_
.OnViewDeleted(view
); }
88 void OnViewVisibilityChanged(uint32_t view
, bool visible
) override
{
89 tracker_
.OnViewVisibilityChanged(view
, visible
);
91 void OnViewDrawnStateChanged(uint32_t view
, bool drawn
) override
{
92 tracker_
.OnViewDrawnStateChanged(view
, drawn
);
94 void OnViewSharedPropertyChanged(uint32_t view
,
96 Array
<uint8_t> new_data
) override
{
97 tracker_
.OnViewSharedPropertyChanged(view
, name
, new_data
.Pass());
99 void OnViewInputEvent(uint32_t view
,
100 mojo::EventPtr event
,
101 const mojo::Callback
<void()>& callback
) override
{
102 tracker_
.OnViewInputEvent(view
, event
.Pass());
104 void OnViewFocused(uint32_t focused_view_id
) override
{
105 tracker_
.OnViewFocused(focused_view_id
);
108 TestChangeTracker tracker_
;
110 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClient
);
113 // -----------------------------------------------------------------------------
115 // ClientConnection implementation that vends TestViewManagerClient.
116 class TestClientConnection
: public ClientConnection
{
118 explicit TestClientConnection(scoped_ptr
<ViewManagerServiceImpl
> service_impl
)
119 : ClientConnection(service_impl
.Pass(), &client_
) {}
120 ~TestClientConnection() override
{}
122 TestViewManagerClient
* client() { return &client_
; }
125 TestViewManagerClient client_
;
127 DISALLOW_COPY_AND_ASSIGN(TestClientConnection
);
130 // -----------------------------------------------------------------------------
132 // Empty implementation of ConnectionManagerDelegate.
133 class TestConnectionManagerDelegate
: public ConnectionManagerDelegate
{
135 TestConnectionManagerDelegate() : last_connection_(nullptr) {}
136 ~TestConnectionManagerDelegate() override
{}
138 TestViewManagerClient
* last_client() {
139 return last_connection_
? last_connection_
->client() : nullptr;
142 TestClientConnection
* last_connection() { return last_connection_
; }
145 // ConnectionManagerDelegate:
146 void OnLostConnectionToWindowManager() override
{}
148 ClientConnection
* CreateClientConnectionForEmbedAtView(
149 ConnectionManager
* connection_manager
,
150 mojo::InterfaceRequest
<mojo::ViewManagerService
> service_request
,
151 mojo::ConnectionSpecificId creator_id
,
152 mojo::URLRequestPtr request
,
153 const ViewId
& root_id
) override
{
154 scoped_ptr
<ViewManagerServiceImpl
> service(
155 new ViewManagerServiceImpl(connection_manager
, creator_id
, root_id
));
156 last_connection_
= new TestClientConnection(service
.Pass());
157 return last_connection_
;
159 ClientConnection
* CreateClientConnectionForEmbedAtView(
160 ConnectionManager
* connection_manager
,
161 mojo::InterfaceRequest
<mojo::ViewManagerService
> service_request
,
162 mojo::ConnectionSpecificId creator_id
,
163 const ViewId
& root_id
,
164 mojo::ViewManagerClientPtr client
) override
{
169 TestClientConnection
* last_connection_
;
171 DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate
);
174 // -----------------------------------------------------------------------------
176 // Empty implementation of nisplayManager.
177 class TestDisplayManager
: public DisplayManager
{
179 TestDisplayManager() {}
180 ~TestDisplayManager() override
{}
183 void Init(DisplayManagerDelegate
* delegate
) override
{}
184 void SchedulePaint(const ServerView
* view
, const gfx::Rect
& bounds
) override
{
186 void SetViewportSize(const gfx::Size
& size
) override
{}
187 const mojo::ViewportMetrics
& GetViewportMetrics() override
{
188 return display_metrices_
;
192 mojo::ViewportMetrics display_metrices_
;
194 DISALLOW_COPY_AND_ASSIGN(TestDisplayManager
);
197 // Factory that dispenses TestDisplayManagers.
198 class TestDisplayManagerFactory
: public DisplayManagerFactory
{
200 TestDisplayManagerFactory() {}
201 ~TestDisplayManagerFactory() {}
202 DisplayManager
* CreateDisplayManager(
204 mojo::ApplicationImpl
* app_impl
,
205 const scoped_refptr
<gles2::GpuState
>& gpu_state9
) override
{
206 return new TestDisplayManager();
210 DISALLOW_COPY_AND_ASSIGN(TestDisplayManagerFactory
);
213 mojo::EventPtr
CreatePointerDownEvent(int x
, int y
) {
214 mojo::EventPtr
event(mojo::Event::New());
215 event
->action
= mojo::EVENT_TYPE_POINTER_DOWN
;
216 event
->pointer_data
= mojo::PointerData::New();
217 event
->pointer_data
->pointer_id
= 1u;
218 event
->pointer_data
->x
= x
;
219 event
->pointer_data
->y
= y
;
223 mojo::EventPtr
CreatePointerUpEvent(int x
, int y
) {
224 mojo::EventPtr
event(mojo::Event::New());
225 event
->action
= mojo::EVENT_TYPE_POINTER_UP
;
226 event
->pointer_data
= mojo::PointerData::New();
227 event
->pointer_data
->pointer_id
= 1u;
228 event
->pointer_data
->x
= x
;
229 event
->pointer_data
->y
= y
;
235 // -----------------------------------------------------------------------------
237 class ViewManagerServiceTest
: public testing::Test
{
239 ViewManagerServiceTest() : wm_client_(nullptr) {}
240 ~ViewManagerServiceTest() override
{}
242 // ViewManagerServiceImpl for the window manager.
243 ViewManagerServiceImpl
* wm_connection() {
244 return connection_manager_
->GetConnection(1);
247 TestViewManagerClient
* last_view_manager_client() {
248 return delegate_
.last_client();
251 TestClientConnection
* last_client_connection() {
252 return delegate_
.last_connection();
255 ConnectionManager
* connection_manager() { return connection_manager_
.get(); }
257 TestViewManagerClient
* wm_client() { return wm_client_
; }
261 void SetUp() override
{
262 DisplayManager::set_factory_for_testing(&display_manager_factory_
);
263 connection_manager_
.reset(
264 new ConnectionManager(&delegate_
, true /* is_headless */, nullptr,
265 scoped_refptr
<gles2::GpuState
>(nullptr)));
266 scoped_ptr
<ViewManagerServiceImpl
> service(new ViewManagerServiceImpl(
267 connection_manager_
.get(), kInvalidConnectionId
, RootViewId(0)));
268 scoped_ptr
<TestClientConnection
> client_connection(
269 new TestClientConnection(service
.Pass()));
270 wm_client_
= client_connection
->client();
271 ASSERT_TRUE(wm_client_
!= nullptr);
272 connection_manager_
->SetWindowManagerClientConnection(
273 client_connection
.Pass());
274 ASSERT_TRUE(wm_connection() != nullptr);
275 ASSERT_TRUE(wm_connection()->root() != nullptr);
279 // TestViewManagerClient that is used for the WM connection.
280 TestViewManagerClient
* wm_client_
;
282 TestDisplayManagerFactory display_manager_factory_
;
283 TestConnectionManagerDelegate delegate_
;
284 scoped_ptr
<ConnectionManager
> connection_manager_
;
285 base::MessageLoop message_loop_
;
287 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceTest
);
292 const ServerView
* GetFirstCloned(const ServerView
* view
) {
293 for (const ServerView
* child
: view
->GetChildren()) {
294 if (child
->id() == ClonedViewId())
300 // Provides common setup for animation tests. Creates the following views:
301 // 0,1 (the root, provided by view manager)
302 // 1,1 the second connection is embedded here (view owned by wm_connection()).
303 // 2,1 bounds=1,2 11x22
304 // 2,2 bounds=2,3 6x7
305 // 2,3 bounds=3,4 6x7
306 // CloneAndAnimate() is invoked for 2,2.
307 void SetUpAnimate1(ViewManagerServiceTest
* test
, ViewId
* embed_view_id
) {
308 *embed_view_id
= ViewId(test
->wm_connection()->id(), 1);
309 EXPECT_EQ(ERROR_CODE_NONE
, test
->wm_connection()->CreateView(*embed_view_id
));
310 EXPECT_TRUE(test
->wm_connection()->SetViewVisibility(*embed_view_id
, true));
311 EXPECT_TRUE(test
->wm_connection()->AddView(*(test
->wm_connection()->root()),
313 mojo::URLRequestPtr
request(mojo::URLRequest::New());
314 test
->wm_connection()->EmbedAllowingReembed(*embed_view_id
, request
.Pass(),
315 mojo::Callback
<void(bool)>());
316 ViewManagerServiceImpl
* connection1
=
317 test
->connection_manager()->GetConnectionWithRoot(*embed_view_id
);
318 ASSERT_TRUE(connection1
!= nullptr);
319 ASSERT_NE(connection1
, test
->wm_connection());
321 const ViewId
child1(connection1
->id(), 1);
322 EXPECT_EQ(ERROR_CODE_NONE
, connection1
->CreateView(child1
));
323 const ViewId
child2(connection1
->id(), 2);
324 EXPECT_EQ(ERROR_CODE_NONE
, connection1
->CreateView(child2
));
325 const ViewId
child3(connection1
->id(), 3);
326 EXPECT_EQ(ERROR_CODE_NONE
, connection1
->CreateView(child3
));
328 ServerView
* v1
= connection1
->GetView(child1
);
329 v1
->SetVisible(true);
330 v1
->SetBounds(gfx::Rect(1, 2, 11, 22));
331 ServerView
* v2
= connection1
->GetView(child2
);
332 v2
->SetVisible(true);
333 v2
->SetBounds(gfx::Rect(2, 3, 6, 7));
334 ServerView
* v3
= connection1
->GetView(child3
);
335 v3
->SetVisible(true);
336 v3
->SetBounds(gfx::Rect(3, 4, 6, 7));
338 EXPECT_TRUE(connection1
->AddView(*embed_view_id
, child1
));
339 EXPECT_TRUE(connection1
->AddView(child1
, child2
));
340 EXPECT_TRUE(connection1
->AddView(child2
, child3
));
342 TestViewManagerClient
* connection1_client
= test
->last_view_manager_client();
343 connection1_client
->tracker()->changes()->clear();
344 test
->wm_client()->tracker()->changes()->clear();
345 EXPECT_TRUE(test
->connection_manager()->CloneAndAnimate(child2
));
346 EXPECT_TRUE(connection1_client
->tracker()->changes()->empty());
347 EXPECT_TRUE(test
->wm_client()->tracker()->changes()->empty());
349 // We cloned v2. The cloned view ends up as a sibling of it.
350 const ServerView
* cloned_view
= GetFirstCloned(connection1
->GetView(child1
));
351 ASSERT_TRUE(cloned_view
);
352 // |cloned_view| should have one and only one cloned child (corresponds to
354 ASSERT_EQ(1u, cloned_view
->GetChildren().size());
355 EXPECT_TRUE(cloned_view
->GetChildren()[0]->id() == ClonedViewId());
357 // Cloned views should match the bounds of the view they were cloned from.
358 EXPECT_EQ(v2
->bounds(), cloned_view
->bounds());
359 EXPECT_EQ(v3
->bounds(), cloned_view
->GetChildren()[0]->bounds());
361 // Cloned views are owned by the ConnectionManager and shouldn't be returned
362 // from ViewManagerServiceImpl::GetView.
363 EXPECT_TRUE(connection1
->GetView(ClonedViewId()) == nullptr);
364 EXPECT_TRUE(test
->wm_connection()->GetView(ClonedViewId()) == nullptr);
369 // Verifies ViewManagerService::GetViewTree() doesn't return cloned views.
370 TEST_F(ViewManagerServiceTest
, ConnectionsCantSeeClonedViews
) {
371 ViewId embed_view_id
;
372 EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id
));
374 ViewManagerServiceImpl
* connection1
=
375 connection_manager()->GetConnectionWithRoot(embed_view_id
);
377 const ViewId
child1(connection1
->id(), 1);
378 const ViewId
child2(connection1
->id(), 2);
379 const ViewId
child3(connection1
->id(), 3);
381 // Verify the root doesn't see any cloned views.
382 std::vector
<const ServerView
*> views(
383 wm_connection()->GetViewTree(*wm_connection()->root()));
384 ASSERT_EQ(5u, views
.size());
385 ASSERT_TRUE(views
[0]->id() == *wm_connection()->root());
386 ASSERT_TRUE(views
[1]->id() == embed_view_id
);
387 ASSERT_TRUE(views
[2]->id() == child1
);
388 ASSERT_TRUE(views
[3]->id() == child2
);
389 ASSERT_TRUE(views
[4]->id() == child3
);
391 // Verify connection1 doesn't see any cloned views.
392 std::vector
<const ServerView
*> v1_views(
393 connection1
->GetViewTree(embed_view_id
));
394 ASSERT_EQ(4u, v1_views
.size());
395 ASSERT_TRUE(v1_views
[0]->id() == embed_view_id
);
396 ASSERT_TRUE(v1_views
[1]->id() == child1
);
397 ASSERT_TRUE(v1_views
[2]->id() == child2
);
398 ASSERT_TRUE(v1_views
[3]->id() == child3
);
401 TEST_F(ViewManagerServiceTest
, ClonedViewsPromotedOnConnectionClose
) {
402 ViewId embed_view_id
;
403 EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id
));
405 // Destroy connection1, which should force the cloned view to become a child
406 // of where it was embedded (the embedded view still exists).
407 connection_manager()->OnConnectionError(last_client_connection());
409 ServerView
* embed_view
= wm_connection()->GetView(embed_view_id
);
410 ASSERT_TRUE(embed_view
!= nullptr);
411 const ServerView
* cloned_view
= GetFirstCloned(embed_view
);
412 ASSERT_TRUE(cloned_view
);
413 ASSERT_EQ(1u, cloned_view
->GetChildren().size());
414 EXPECT_TRUE(cloned_view
->GetChildren()[0]->id() == ClonedViewId());
416 // Because the cloned view changed parents its bounds should have changed.
417 EXPECT_EQ(gfx::Rect(3, 5, 6, 7), cloned_view
->bounds());
418 // The bounds of the cloned child should not have changed though.
419 EXPECT_EQ(gfx::Rect(3, 4, 6, 7), cloned_view
->GetChildren()[0]->bounds());
422 TEST_F(ViewManagerServiceTest
, ClonedViewsPromotedOnHide
) {
423 ViewId embed_view_id
;
424 EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id
));
426 ViewManagerServiceImpl
* connection1
=
427 connection_manager()->GetConnectionWithRoot(embed_view_id
);
429 // Hide the parent of the cloned view, which should force the cloned view to
430 // become a sibling of the parent.
431 const ServerView
* view_to_hide
=
432 connection1
->GetView(ViewId(connection1
->id(), 1));
433 ASSERT_TRUE(connection1
->SetViewVisibility(view_to_hide
->id(), false));
435 const ServerView
* cloned_view
= GetFirstCloned(view_to_hide
->parent());
436 ASSERT_TRUE(cloned_view
);
437 ASSERT_EQ(1u, cloned_view
->GetChildren().size());
438 EXPECT_TRUE(cloned_view
->GetChildren()[0]->id() == ClonedViewId());
439 EXPECT_EQ(2u, cloned_view
->parent()->GetChildren().size());
440 EXPECT_TRUE(cloned_view
->parent()->GetChildren()[1] == cloned_view
);
443 // Clone and animate on a tree with more depth. Basically that of
444 // SetUpAnimate1() but cloning 2,1.
445 TEST_F(ViewManagerServiceTest
, CloneAndAnimateLargerDepth
) {
446 const ViewId
embed_view_id(wm_connection()->id(), 1);
447 EXPECT_EQ(ERROR_CODE_NONE
, wm_connection()->CreateView(embed_view_id
));
448 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id
, true));
450 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id
));
451 mojo::URLRequestPtr
request(mojo::URLRequest::New());
452 wm_connection()->EmbedAllowingReembed(embed_view_id
, request
.Pass(),
453 mojo::Callback
<void(bool)>());
454 ViewManagerServiceImpl
* connection1
=
455 connection_manager()->GetConnectionWithRoot(embed_view_id
);
456 ASSERT_TRUE(connection1
!= nullptr);
457 ASSERT_NE(connection1
, wm_connection());
459 const ViewId
child1(connection1
->id(), 1);
460 EXPECT_EQ(ERROR_CODE_NONE
, connection1
->CreateView(child1
));
461 const ViewId
child2(connection1
->id(), 2);
462 EXPECT_EQ(ERROR_CODE_NONE
, connection1
->CreateView(child2
));
463 const ViewId
child3(connection1
->id(), 3);
464 EXPECT_EQ(ERROR_CODE_NONE
, connection1
->CreateView(child3
));
466 ServerView
* v1
= connection1
->GetView(child1
);
467 v1
->SetVisible(true);
468 connection1
->GetView(child2
)->SetVisible(true);
469 connection1
->GetView(child3
)->SetVisible(true);
471 EXPECT_TRUE(connection1
->AddView(embed_view_id
, child1
));
472 EXPECT_TRUE(connection1
->AddView(child1
, child2
));
473 EXPECT_TRUE(connection1
->AddView(child2
, child3
));
475 TestViewManagerClient
* connection1_client
= last_view_manager_client();
476 connection1_client
->tracker()->changes()->clear();
477 wm_client()->tracker()->changes()->clear();
478 EXPECT_TRUE(connection_manager()->CloneAndAnimate(child1
));
479 EXPECT_TRUE(connection1_client
->tracker()->changes()->empty());
480 EXPECT_TRUE(wm_client()->tracker()->changes()->empty());
482 // We cloned v1. The cloned view ends up as a sibling of it.
483 const ServerView
* cloned_view
= GetFirstCloned(v1
->parent());
484 ASSERT_TRUE(cloned_view
);
485 // |cloned_view| should have a child and its child should have a child.
486 ASSERT_EQ(1u, cloned_view
->GetChildren().size());
487 const ServerView
* cloned_view_child
= cloned_view
->GetChildren()[0];
488 EXPECT_EQ(1u, cloned_view_child
->GetChildren().size());
489 EXPECT_TRUE(cloned_view_child
->id() == ClonedViewId());
492 // Verifies focus correctly changes on pointer events.
493 TEST_F(ViewManagerServiceTest
, FocusOnPointer
) {
494 const ViewId
embed_view_id(wm_connection()->id(), 1);
495 EXPECT_EQ(ERROR_CODE_NONE
, wm_connection()->CreateView(embed_view_id
));
496 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id
, true));
498 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id
));
499 connection_manager()->view_manager_root()->root_view()->SetBounds(
500 gfx::Rect(0, 0, 100, 100));
501 mojo::URLRequestPtr
request(mojo::URLRequest::New());
502 wm_connection()->EmbedAllowingReembed(embed_view_id
, request
.Pass(),
503 mojo::Callback
<void(bool)>());
504 ViewManagerServiceImpl
* connection1
=
505 connection_manager()->GetConnectionWithRoot(embed_view_id
);
506 ASSERT_TRUE(connection1
!= nullptr);
507 ASSERT_NE(connection1
, wm_connection());
510 ->GetView(embed_view_id
)
511 ->SetBounds(gfx::Rect(0, 0, 50, 50));
513 const ViewId
child1(connection1
->id(), 1);
514 EXPECT_EQ(ERROR_CODE_NONE
, connection1
->CreateView(child1
));
515 EXPECT_TRUE(connection1
->AddView(embed_view_id
, child1
));
516 ServerView
* v1
= connection1
->GetView(child1
);
517 v1
->SetVisible(true);
518 v1
->SetBounds(gfx::Rect(20, 20, 20, 20));
520 TestViewManagerClient
* connection1_client
= last_view_manager_client();
521 connection1_client
->tracker()->changes()->clear();
522 wm_client()->tracker()->changes()->clear();
524 connection_manager()->OnEvent(connection_manager()->view_manager_root(),
525 CreatePointerDownEvent(21, 22));
526 // Focus should go to child1. This results in notifying both the window
527 // manager and client connection being notified.
528 EXPECT_EQ(v1
, connection_manager()->GetFocusedView());
529 ASSERT_GE(wm_client()->tracker()->changes()->size(), 1u);
530 EXPECT_EQ("Focused id=2,1",
531 ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
532 ASSERT_GE(connection1_client
->tracker()->changes()->size(), 1u);
535 ChangesToDescription1(*connection1_client
->tracker()->changes())[0]);
537 connection_manager()->OnEvent(connection_manager()->view_manager_root(),
538 CreatePointerUpEvent(21, 22));
539 wm_client()->tracker()->changes()->clear();
540 connection1_client
->tracker()->changes()->clear();
542 // Press outside of the embedded view. Focus should go to the root. Notice
543 // the client1 doesn't see who has focus as the focused view (root) isn't
545 connection_manager()->OnEvent(connection_manager()->view_manager_root(),
546 CreatePointerDownEvent(61, 22));
547 EXPECT_EQ(connection_manager()->view_manager_root()->root_view(),
548 connection_manager()->GetFocusedView());
549 ASSERT_GE(wm_client()->tracker()->changes()->size(), 1u);
550 EXPECT_EQ("Focused id=0,2",
551 ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
552 ASSERT_GE(connection1_client
->tracker()->changes()->size(), 1u);
555 ChangesToDescription1(*connection1_client
->tracker()->changes())[0]);
557 connection_manager()->OnEvent(connection_manager()->view_manager_root(),
558 CreatePointerUpEvent(21, 22));
559 wm_client()->tracker()->changes()->clear();
560 connection1_client
->tracker()->changes()->clear();
562 // Press in the same location. Should not get a focus change event (only input
564 connection_manager()->OnEvent(connection_manager()->view_manager_root(),
565 CreatePointerDownEvent(61, 22));
566 EXPECT_EQ(connection_manager()->view_manager_root()->root_view(),
567 connection_manager()->GetFocusedView());
568 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u);
569 EXPECT_EQ("InputEvent view=0,2 event_action=4",
570 ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
571 EXPECT_TRUE(connection1_client
->tracker()->changes()->empty());
575 } // namespace view_manager