Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / components / view_manager / view_manager_service_unittest.cc
blob970b47ed43f0869dbe4c13790ea13aedbd13ff5a
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.
5 #include <string>
6 #include <vector>
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/ids.h"
14 #include "components/view_manager/public/cpp/types.h"
15 #include "components/view_manager/public/cpp/util.h"
16 #include "components/view_manager/public/interfaces/view_manager.mojom.h"
17 #include "components/view_manager/server_view.h"
18 #include "components/view_manager/test_change_tracker.h"
19 #include "components/view_manager/view_manager_service_impl.h"
20 #include "mojo/application/public/interfaces/service_provider.mojom.h"
21 #include "mojo/converters/geometry/geometry_type_converters.h"
22 #include "testing/gtest/include/gtest/gtest.h"
23 #include "ui/gfx/geometry/rect.h"
25 using mojo::Array;
26 using mojo::ERROR_CODE_NONE;
27 using mojo::InterfaceRequest;
28 using mojo::ServiceProvider;
29 using mojo::ServiceProviderPtr;
30 using mojo::String;
31 using mojo::ViewDataPtr;
33 namespace view_manager {
34 namespace {
36 // -----------------------------------------------------------------------------
38 // ViewManagerClient implementation that logs all calls to a TestChangeTracker.
39 // TODO(sky): refactor so both this and ViewManagerServiceAppTest share code.
40 class TestViewManagerClient : public mojo::ViewManagerClient {
41 public:
42 TestViewManagerClient() {}
43 ~TestViewManagerClient() override {}
45 TestChangeTracker* tracker() { return &tracker_; }
47 private:
48 // ViewManagerClient:
49 void OnEmbed(uint16_t connection_id,
50 const String& embedder_url,
51 ViewDataPtr root,
52 mojo::ViewManagerServicePtr view_manager_service,
53 InterfaceRequest<ServiceProvider> services,
54 ServiceProviderPtr exposed_services,
55 mojo::Id focused_view_id) override {
56 // TODO(sky): add test coverage of |focused_view_id|.
57 tracker_.OnEmbed(connection_id, embedder_url, root.Pass());
59 void OnWillEmbed(uint32_t view,
60 mojo::InterfaceRequest<mojo::ServiceProvider> services,
61 mojo::ServiceProviderPtr exposed_services,
62 const OnWillEmbedCallback& callback) override {}
63 void OnEmbeddedAppDisconnected(uint32_t view) override {
64 tracker_.OnEmbeddedAppDisconnected(view);
66 void OnViewBoundsChanged(uint32_t view,
67 mojo::RectPtr old_bounds,
68 mojo::RectPtr new_bounds) override {
69 tracker_.OnViewBoundsChanged(view, old_bounds.Pass(), new_bounds.Pass());
71 void OnViewViewportMetricsChanged(
72 mojo::ViewportMetricsPtr old_metrics,
73 mojo::ViewportMetricsPtr new_metrics) override {
74 tracker_.OnViewViewportMetricsChanged(old_metrics.Pass(),
75 new_metrics.Pass());
77 void OnViewHierarchyChanged(uint32_t view,
78 uint32_t new_parent,
79 uint32_t old_parent,
80 Array<ViewDataPtr> views) override {
81 tracker_.OnViewHierarchyChanged(view, new_parent, old_parent, views.Pass());
83 void OnViewReordered(uint32_t view_id,
84 uint32_t relative_view_id,
85 mojo::OrderDirection direction) override {
86 tracker_.OnViewReordered(view_id, relative_view_id, direction);
88 void OnViewDeleted(uint32_t view) override { tracker_.OnViewDeleted(view); }
89 void OnViewVisibilityChanged(uint32_t view, bool visible) override {
90 tracker_.OnViewVisibilityChanged(view, visible);
92 void OnViewDrawnStateChanged(uint32_t view, bool drawn) override {
93 tracker_.OnViewDrawnStateChanged(view, drawn);
95 void OnViewSharedPropertyChanged(uint32_t view,
96 const String& name,
97 Array<uint8_t> new_data) override {
98 tracker_.OnViewSharedPropertyChanged(view, name, new_data.Pass());
100 void OnViewInputEvent(uint32_t view,
101 mojo::EventPtr event,
102 const mojo::Callback<void()>& callback) override {
103 tracker_.OnViewInputEvent(view, event.Pass());
105 void OnViewFocused(uint32_t focused_view_id) override {
106 tracker_.OnViewFocused(focused_view_id);
109 TestChangeTracker tracker_;
111 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClient);
114 // -----------------------------------------------------------------------------
116 // ClientConnection implementation that vends TestViewManagerClient.
117 class TestClientConnection : public ClientConnection {
118 public:
119 explicit TestClientConnection(scoped_ptr<ViewManagerServiceImpl> service_impl)
120 : ClientConnection(service_impl.Pass(), &client_) {}
121 ~TestClientConnection() override {}
123 TestViewManagerClient* client() { return &client_; }
125 private:
126 TestViewManagerClient client_;
128 DISALLOW_COPY_AND_ASSIGN(TestClientConnection);
131 // -----------------------------------------------------------------------------
133 // Empty implementation of ConnectionManagerDelegate.
134 class TestConnectionManagerDelegate : public ConnectionManagerDelegate {
135 public:
136 TestConnectionManagerDelegate() : last_connection_(nullptr) {}
137 ~TestConnectionManagerDelegate() override {}
139 TestViewManagerClient* last_client() {
140 return last_connection_ ? last_connection_->client() : nullptr;
143 TestClientConnection* last_connection() { return last_connection_; }
145 private:
146 // ConnectionManagerDelegate:
147 void OnLostConnectionToWindowManager() override {}
149 ClientConnection* CreateClientConnectionForEmbedAtView(
150 ConnectionManager* connection_manager,
151 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
152 mojo::ConnectionSpecificId creator_id,
153 const std::string& creator_url,
154 mojo::URLRequestPtr request,
155 const ViewId& root_id) override {
156 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl(
157 connection_manager, creator_id, creator_url, request->url, root_id));
158 last_connection_ = new TestClientConnection(service.Pass());
159 return last_connection_;
161 ClientConnection* CreateClientConnectionForEmbedAtView(
162 ConnectionManager* connection_manager,
163 mojo::InterfaceRequest<mojo::ViewManagerService> service_request,
164 mojo::ConnectionSpecificId creator_id,
165 const std::string& creator_url,
166 const ViewId& root_id,
167 mojo::ViewManagerClientPtr client) override {
168 NOTIMPLEMENTED();
169 return nullptr;
172 TestClientConnection* last_connection_;
174 DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate);
177 // -----------------------------------------------------------------------------
179 // Empty implementation of DisplayManager.
180 class TestDisplayManager : public DisplayManager {
181 public:
182 TestDisplayManager() {}
183 ~TestDisplayManager() override {}
185 // DisplayManager:
186 void Init(ConnectionManager* connection_manager,
187 mojo::NativeViewportEventDispatcherPtr event_dispatcher) override {}
188 void SchedulePaint(const ServerView* view, const gfx::Rect& bounds) override {
190 void SetViewportSize(const gfx::Size& size) override {}
191 const mojo::ViewportMetrics& GetViewportMetrics() override {
192 return display_metrices_;
195 private:
196 mojo::ViewportMetrics display_metrices_;
198 DISALLOW_COPY_AND_ASSIGN(TestDisplayManager);
201 mojo::EventPtr CreatePointerDownEvent(int x, int y) {
202 mojo::EventPtr event(mojo::Event::New());
203 event->action = mojo::EVENT_TYPE_POINTER_DOWN;
204 event->pointer_data = mojo::PointerData::New();
205 event->pointer_data->pointer_id = 1u;
206 event->pointer_data->x = x;
207 event->pointer_data->y = y;
208 return event.Pass();
211 mojo::EventPtr CreatePointerUpEvent(int x, int y) {
212 mojo::EventPtr event(mojo::Event::New());
213 event->action = mojo::EVENT_TYPE_POINTER_UP;
214 event->pointer_data = mojo::PointerData::New();
215 event->pointer_data->pointer_id = 1u;
216 event->pointer_data->x = x;
217 event->pointer_data->y = y;
218 return event.Pass();
221 } // namespace
223 // -----------------------------------------------------------------------------
225 class ViewManagerServiceTest : public testing::Test {
226 public:
227 ViewManagerServiceTest() : wm_client_(nullptr) {}
228 ~ViewManagerServiceTest() override {}
230 // ViewManagerServiceImpl for the window manager.
231 ViewManagerServiceImpl* wm_connection() {
232 return connection_manager_->GetConnection(1);
235 TestViewManagerClient* last_view_manager_client() {
236 return delegate_.last_client();
239 TestClientConnection* last_client_connection() {
240 return delegate_.last_connection();
243 ConnectionManager* connection_manager() { return connection_manager_.get(); }
245 TestViewManagerClient* wm_client() { return wm_client_; }
247 protected:
248 // testing::Test:
249 void SetUp() override {
250 connection_manager_.reset(new ConnectionManager(
251 &delegate_, scoped_ptr<DisplayManager>(new TestDisplayManager)));
252 scoped_ptr<ViewManagerServiceImpl> service(new ViewManagerServiceImpl(
253 connection_manager_.get(), kInvalidConnectionId, std::string(),
254 std::string("mojo:window_manager"), RootViewId()));
255 scoped_ptr<TestClientConnection> client_connection(
256 new TestClientConnection(service.Pass()));
257 wm_client_ = client_connection->client();
258 ASSERT_TRUE(wm_client_ != nullptr);
259 connection_manager_->SetWindowManagerClientConnection(
260 client_connection.Pass());
261 ASSERT_TRUE(wm_connection() != nullptr);
262 ASSERT_TRUE(wm_connection()->root() != nullptr);
265 private:
266 // TestViewManagerClient that is used for the WM connection.
267 TestViewManagerClient* wm_client_;
269 TestConnectionManagerDelegate delegate_;
270 scoped_ptr<ConnectionManager> connection_manager_;
271 base::MessageLoop message_loop_;
273 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceTest);
276 namespace {
278 const ServerView* GetFirstCloned(const ServerView* view) {
279 for (const ServerView* child : view->GetChildren()) {
280 if (child->id() == ClonedViewId())
281 return child;
283 return nullptr;
286 // Provides common setup for animation tests. Creates the following views:
287 // 0,1 (the root, provided by view manager)
288 // 1,1 the second connection is embedded here (view owned by wm_connection()).
289 // 2,1 bounds=1,2 11x22
290 // 2,2 bounds=2,3 6x7
291 // 2,3 bounds=3,4 6x7
292 // CloneAndAnimate() is invoked for 2,2.
293 void SetUpAnimate1(ViewManagerServiceTest* test, ViewId* embed_view_id) {
294 *embed_view_id = ViewId(test->wm_connection()->id(), 1);
295 EXPECT_EQ(ERROR_CODE_NONE, test->wm_connection()->CreateView(*embed_view_id));
296 EXPECT_TRUE(test->wm_connection()->SetViewVisibility(*embed_view_id, true));
297 EXPECT_TRUE(test->wm_connection()->AddView(*(test->wm_connection()->root()),
298 *embed_view_id));
299 mojo::URLRequestPtr request(mojo::URLRequest::New());
300 test->wm_connection()->Embed(request.Pass(), *embed_view_id,
301 ViewManagerServiceImpl::EmbedType::NO_REEMBED,
302 nullptr, nullptr, mojo::Callback<void(bool)>());
303 ViewManagerServiceImpl* connection1 =
304 test->connection_manager()->GetConnectionWithRoot(*embed_view_id);
305 ASSERT_TRUE(connection1 != nullptr);
306 ASSERT_NE(connection1, test->wm_connection());
308 const ViewId child1(connection1->id(), 1);
309 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1));
310 const ViewId child2(connection1->id(), 2);
311 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2));
312 const ViewId child3(connection1->id(), 3);
313 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child3));
315 ServerView* v1 = connection1->GetView(child1);
316 v1->SetVisible(true);
317 v1->SetBounds(gfx::Rect(1, 2, 11, 22));
318 ServerView* v2 = connection1->GetView(child2);
319 v2->SetVisible(true);
320 v2->SetBounds(gfx::Rect(2, 3, 6, 7));
321 ServerView* v3 = connection1->GetView(child3);
322 v3->SetVisible(true);
323 v3->SetBounds(gfx::Rect(3, 4, 6, 7));
325 EXPECT_TRUE(connection1->AddView(*embed_view_id, child1));
326 EXPECT_TRUE(connection1->AddView(child1, child2));
327 EXPECT_TRUE(connection1->AddView(child2, child3));
329 TestViewManagerClient* connection1_client = test->last_view_manager_client();
330 connection1_client->tracker()->changes()->clear();
331 test->wm_client()->tracker()->changes()->clear();
332 EXPECT_TRUE(test->connection_manager()->CloneAndAnimate(child2));
333 EXPECT_TRUE(connection1_client->tracker()->changes()->empty());
334 EXPECT_TRUE(test->wm_client()->tracker()->changes()->empty());
336 // We cloned v2. The cloned view ends up as a sibling of it.
337 const ServerView* cloned_view = GetFirstCloned(connection1->GetView(child1));
338 ASSERT_TRUE(cloned_view);
339 // |cloned_view| should have one and only one cloned child (corresponds to
340 // |child3|).
341 ASSERT_EQ(1u, cloned_view->GetChildren().size());
342 EXPECT_TRUE(cloned_view->GetChildren()[0]->id() == ClonedViewId());
344 // Cloned views should match the bounds of the view they were cloned from.
345 EXPECT_EQ(v2->bounds(), cloned_view->bounds());
346 EXPECT_EQ(v3->bounds(), cloned_view->GetChildren()[0]->bounds());
348 // Cloned views are owned by the ConnectionManager and shouldn't be returned
349 // from ViewManagerServiceImpl::GetView.
350 EXPECT_TRUE(connection1->GetView(ClonedViewId()) == nullptr);
351 EXPECT_TRUE(test->wm_connection()->GetView(ClonedViewId()) == nullptr);
354 } // namespace
356 // Verifies ViewManagerService::GetViewTree() doesn't return cloned views.
357 TEST_F(ViewManagerServiceTest, ConnectionsCantSeeClonedViews) {
358 ViewId embed_view_id;
359 EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id));
361 ViewManagerServiceImpl* connection1 =
362 connection_manager()->GetConnectionWithRoot(embed_view_id);
364 const ViewId child1(connection1->id(), 1);
365 const ViewId child2(connection1->id(), 2);
366 const ViewId child3(connection1->id(), 3);
368 // Verify the root doesn't see any cloned views.
369 std::vector<const ServerView*> views(
370 wm_connection()->GetViewTree(*wm_connection()->root()));
371 ASSERT_EQ(5u, views.size());
372 ASSERT_TRUE(views[0]->id() == *wm_connection()->root());
373 ASSERT_TRUE(views[1]->id() == embed_view_id);
374 ASSERT_TRUE(views[2]->id() == child1);
375 ASSERT_TRUE(views[3]->id() == child2);
376 ASSERT_TRUE(views[4]->id() == child3);
378 // Verify connection1 doesn't see any cloned views.
379 std::vector<const ServerView*> v1_views(
380 connection1->GetViewTree(embed_view_id));
381 ASSERT_EQ(4u, v1_views.size());
382 ASSERT_TRUE(v1_views[0]->id() == embed_view_id);
383 ASSERT_TRUE(v1_views[1]->id() == child1);
384 ASSERT_TRUE(v1_views[2]->id() == child2);
385 ASSERT_TRUE(v1_views[3]->id() == child3);
388 TEST_F(ViewManagerServiceTest, ClonedViewsPromotedOnConnectionClose) {
389 ViewId embed_view_id;
390 EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id));
392 // Destroy connection1, which should force the cloned view to become a child
393 // of where it was embedded (the embedded view still exists).
394 connection_manager()->OnConnectionError(last_client_connection());
396 ServerView* embed_view = wm_connection()->GetView(embed_view_id);
397 ASSERT_TRUE(embed_view != nullptr);
398 const ServerView* cloned_view = GetFirstCloned(embed_view);
399 ASSERT_TRUE(cloned_view);
400 ASSERT_EQ(1u, cloned_view->GetChildren().size());
401 EXPECT_TRUE(cloned_view->GetChildren()[0]->id() == ClonedViewId());
403 // Because the cloned view changed parents its bounds should have changed.
404 EXPECT_EQ(gfx::Rect(3, 5, 6, 7), cloned_view->bounds());
405 // The bounds of the cloned child should not have changed though.
406 EXPECT_EQ(gfx::Rect(3, 4, 6, 7), cloned_view->GetChildren()[0]->bounds());
409 TEST_F(ViewManagerServiceTest, ClonedViewsPromotedOnHide) {
410 ViewId embed_view_id;
411 EXPECT_NO_FATAL_FAILURE(SetUpAnimate1(this, &embed_view_id));
413 ViewManagerServiceImpl* connection1 =
414 connection_manager()->GetConnectionWithRoot(embed_view_id);
416 // Hide the parent of the cloned view, which should force the cloned view to
417 // become a sibling of the parent.
418 const ServerView* view_to_hide =
419 connection1->GetView(ViewId(connection1->id(), 1));
420 ASSERT_TRUE(connection1->SetViewVisibility(view_to_hide->id(), false));
422 const ServerView* cloned_view = GetFirstCloned(view_to_hide->parent());
423 ASSERT_TRUE(cloned_view);
424 ASSERT_EQ(1u, cloned_view->GetChildren().size());
425 EXPECT_TRUE(cloned_view->GetChildren()[0]->id() == ClonedViewId());
426 EXPECT_EQ(2u, cloned_view->parent()->GetChildren().size());
427 EXPECT_TRUE(cloned_view->parent()->GetChildren()[1] == cloned_view);
430 // Clone and animate on a tree with more depth. Basically that of
431 // SetUpAnimate1() but cloning 2,1.
432 TEST_F(ViewManagerServiceTest, CloneAndAnimateLargerDepth) {
433 const ViewId embed_view_id(wm_connection()->id(), 1);
434 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id));
435 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true));
436 EXPECT_TRUE(
437 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id));
438 mojo::URLRequestPtr request(mojo::URLRequest::New());
439 wm_connection()->Embed(request.Pass(), embed_view_id,
440 ViewManagerServiceImpl::EmbedType::NO_REEMBED, nullptr,
441 nullptr, mojo::Callback<void(bool)>());
442 ViewManagerServiceImpl* connection1 =
443 connection_manager()->GetConnectionWithRoot(embed_view_id);
444 ASSERT_TRUE(connection1 != nullptr);
445 ASSERT_NE(connection1, wm_connection());
447 const ViewId child1(connection1->id(), 1);
448 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1));
449 const ViewId child2(connection1->id(), 2);
450 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child2));
451 const ViewId child3(connection1->id(), 3);
452 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child3));
454 ServerView* v1 = connection1->GetView(child1);
455 v1->SetVisible(true);
456 connection1->GetView(child2)->SetVisible(true);
457 connection1->GetView(child3)->SetVisible(true);
459 EXPECT_TRUE(connection1->AddView(embed_view_id, child1));
460 EXPECT_TRUE(connection1->AddView(child1, child2));
461 EXPECT_TRUE(connection1->AddView(child2, child3));
463 TestViewManagerClient* connection1_client = last_view_manager_client();
464 connection1_client->tracker()->changes()->clear();
465 wm_client()->tracker()->changes()->clear();
466 EXPECT_TRUE(connection_manager()->CloneAndAnimate(child1));
467 EXPECT_TRUE(connection1_client->tracker()->changes()->empty());
468 EXPECT_TRUE(wm_client()->tracker()->changes()->empty());
470 // We cloned v1. The cloned view ends up as a sibling of it.
471 const ServerView* cloned_view = GetFirstCloned(v1->parent());
472 ASSERT_TRUE(cloned_view);
473 // |cloned_view| should have a child and its child should have a child.
474 ASSERT_EQ(1u, cloned_view->GetChildren().size());
475 const ServerView* cloned_view_child = cloned_view->GetChildren()[0];
476 EXPECT_EQ(1u, cloned_view_child->GetChildren().size());
477 EXPECT_TRUE(cloned_view_child->id() == ClonedViewId());
480 // Verifies focus correctly changes on pointer events.
481 TEST_F(ViewManagerServiceTest, FocusOnPointer) {
482 const ViewId embed_view_id(wm_connection()->id(), 1);
483 EXPECT_EQ(ERROR_CODE_NONE, wm_connection()->CreateView(embed_view_id));
484 EXPECT_TRUE(wm_connection()->SetViewVisibility(embed_view_id, true));
485 EXPECT_TRUE(
486 wm_connection()->AddView(*(wm_connection()->root()), embed_view_id));
487 connection_manager()->root()->SetBounds(gfx::Rect(0, 0, 100, 100));
488 mojo::URLRequestPtr request(mojo::URLRequest::New());
489 wm_connection()->Embed(request.Pass(), embed_view_id,
490 ViewManagerServiceImpl::EmbedType::NO_REEMBED, nullptr,
491 nullptr, mojo::Callback<void(bool)>());
492 ViewManagerServiceImpl* connection1 =
493 connection_manager()->GetConnectionWithRoot(embed_view_id);
494 ASSERT_TRUE(connection1 != nullptr);
495 ASSERT_NE(connection1, wm_connection());
497 connection_manager()
498 ->GetView(embed_view_id)
499 ->SetBounds(gfx::Rect(0, 0, 50, 50));
501 const ViewId child1(connection1->id(), 1);
502 EXPECT_EQ(ERROR_CODE_NONE, connection1->CreateView(child1));
503 EXPECT_TRUE(connection1->AddView(embed_view_id, child1));
504 ServerView* v1 = connection1->GetView(child1);
505 v1->SetVisible(true);
506 v1->SetBounds(gfx::Rect(20, 20, 20, 20));
508 TestViewManagerClient* connection1_client = last_view_manager_client();
509 connection1_client->tracker()->changes()->clear();
510 wm_client()->tracker()->changes()->clear();
512 connection_manager()->ProcessEvent(CreatePointerDownEvent(21, 22));
513 // Focus should go to child1. This results in notifying both the window
514 // manager and client connection being notified.
515 EXPECT_EQ(v1, connection_manager()->GetFocusedView());
516 ASSERT_GE(wm_client()->tracker()->changes()->size(), 1u);
517 EXPECT_EQ("Focused id=2,1",
518 ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
519 ASSERT_GE(connection1_client->tracker()->changes()->size(), 1u);
520 EXPECT_EQ(
521 "Focused id=2,1",
522 ChangesToDescription1(*connection1_client->tracker()->changes())[0]);
524 connection_manager()->ProcessEvent(CreatePointerUpEvent(21, 22));
525 wm_client()->tracker()->changes()->clear();
526 connection1_client->tracker()->changes()->clear();
528 // Press outside of the embedded view. Focus should go to the root. Notice
529 // the client1 doesn't see who has focus as the focused view (root) isn't
530 // visible to it.
531 connection_manager()->ProcessEvent(CreatePointerDownEvent(61, 22));
532 EXPECT_EQ(connection_manager()->root(),
533 connection_manager()->GetFocusedView());
534 ASSERT_GE(wm_client()->tracker()->changes()->size(), 1u);
535 EXPECT_EQ("Focused id=0,1",
536 ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
537 ASSERT_GE(connection1_client->tracker()->changes()->size(), 1u);
538 EXPECT_EQ(
539 "Focused id=null",
540 ChangesToDescription1(*connection1_client->tracker()->changes())[0]);
542 connection_manager()->ProcessEvent(CreatePointerUpEvent(21, 22));
543 wm_client()->tracker()->changes()->clear();
544 connection1_client->tracker()->changes()->clear();
546 // Press in the same location. Should not get a focus change event (only input
547 // event).
548 connection_manager()->ProcessEvent(CreatePointerDownEvent(61, 22));
549 EXPECT_EQ(connection_manager()->root(),
550 connection_manager()->GetFocusedView());
551 ASSERT_EQ(wm_client()->tracker()->changes()->size(), 1u);
552 EXPECT_EQ("InputEvent view=0,1 event_action=4",
553 ChangesToDescription1(*wm_client()->tracker()->changes())[0]);
554 EXPECT_TRUE(connection1_client->tracker()->changes()->empty());
558 } // namespace view_manager