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

Side by Side Diff: ui/views/mus/native_widget_mus_unittest.cc

Issue 2018823002: Eliminate WindowTreeConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@connection
Patch Set: . Created 4 years, 6 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 | « ui/views/mus/native_widget_mus.cc ('k') | ui/views/mus/surface_binding.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ui/views/mus/native_widget_mus.h" 5 #include "ui/views/mus/native_widget_mus.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "components/mus/public/cpp/property_type_converters.h" 9 #include "components/mus/public/cpp/property_type_converters.h"
10 #include "components/mus/public/cpp/tests/window_tree_client_impl_private.h" 10 #include "components/mus/public/cpp/tests/window_tree_client_private.h"
11 #include "components/mus/public/cpp/window.h" 11 #include "components/mus/public/cpp/window.h"
12 #include "components/mus/public/cpp/window_property.h" 12 #include "components/mus/public/cpp/window_property.h"
13 #include "components/mus/public/cpp/window_tree_connection.h" 13 #include "components/mus/public/cpp/window_tree_client.h"
14 #include "components/mus/public/interfaces/window_manager.mojom.h" 14 #include "components/mus/public/interfaces/window_manager.mojom.h"
15 #include "components/mus/public/interfaces/window_tree.mojom.h" 15 #include "components/mus/public/interfaces/window_tree.mojom.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
18 #include "third_party/skia/include/core/SkColor.h" 18 #include "third_party/skia/include/core/SkColor.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/events/event.h" 20 #include "ui/events/event.h"
21 #include "ui/events/test/test_event_handler.h" 21 #include "ui/events/test/test_event_handler.h"
22 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
23 #include "ui/gfx/image/image_skia.h" 23 #include "ui/gfx/image/image_skia.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); 341 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
342 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 342 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
343 widget.Init(params); 343 widget.Init(params);
344 widget.Show(); 344 widget.Show();
345 mus::Window* window = 345 mus::Window* window =
346 static_cast<NativeWidgetMus*>(widget.native_widget_private())->window(); 346 static_cast<NativeWidgetMus*>(widget.native_widget_private())->window();
347 ASSERT_TRUE(window->visible()); 347 ASSERT_TRUE(window->visible());
348 348
349 // Create a child window, make it visible and parent it to the Widget's 349 // Create a child window, make it visible and parent it to the Widget's
350 // window. 350 // window.
351 mus::Window* child_window = window->connection()->NewWindow(); 351 mus::Window* child_window = window->window_tree()->NewWindow();
352 child_window->SetVisible(true); 352 child_window->SetVisible(true);
353 window->AddChild(child_window); 353 window->AddChild(child_window);
354 354
355 // Hide the child, this should not impact the visibility of the parent. 355 // Hide the child, this should not impact the visibility of the parent.
356 child_window->SetVisible(false); 356 child_window->SetVisible(false);
357 EXPECT_TRUE(window->visible()); 357 EXPECT_TRUE(window->visible());
358 } 358 }
359 359
360 // Tests that child aura::Windows cannot be activated. 360 // Tests that child aura::Windows cannot be activated.
361 TEST_F(NativeWidgetMusTest, FocusChildAuraWindow) { 361 TEST_F(NativeWidgetMusTest, FocusChildAuraWindow) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 View* content = new HandleMousePressView; 409 View* content = new HandleMousePressView;
410 content->SetBounds(10, 20, 90, 180); 410 content->SetBounds(10, 20, 90, 180);
411 widget->GetContentsView()->AddChildView(content); 411 widget->GetContentsView()->AddChildView(content);
412 412
413 ui::test::TestEventHandler handler; 413 ui::test::TestEventHandler handler;
414 content->AddPreTargetHandler(&handler); 414 content->AddPreTargetHandler(&handler);
415 415
416 std::unique_ptr<ui::MouseEvent> mouse = CreateMouseEvent(); 416 std::unique_ptr<ui::MouseEvent> mouse = CreateMouseEvent();
417 NativeWidgetMus* native_widget = 417 NativeWidgetMus* native_widget =
418 static_cast<NativeWidgetMus*>(widget->native_widget_private()); 418 static_cast<NativeWidgetMus*>(widget->native_widget_private());
419 mus::WindowTreeClientImplPrivate test_api(native_widget->window()); 419 mus::WindowTreeClientPrivate test_api(native_widget->window());
420 test_api.CallOnWindowInputEvent(native_widget->window(), *mouse); 420 test_api.CallOnWindowInputEvent(native_widget->window(), *mouse);
421 EXPECT_EQ(1, handler.num_mouse_events()); 421 EXPECT_EQ(1, handler.num_mouse_events());
422 } 422 }
423 423
424 // Tests that an incoming UI event is acked with the handled status. 424 // Tests that an incoming UI event is acked with the handled status.
425 TEST_F(NativeWidgetMusTest, EventAcked) { 425 TEST_F(NativeWidgetMusTest, EventAcked) {
426 std::unique_ptr<Widget> widget(CreateWidget(nullptr)); 426 std::unique_ptr<Widget> widget(CreateWidget(nullptr));
427 widget->Show(); 427 widget->Show();
428 428
429 View* content = new HandleMousePressView; 429 View* content = new HandleMousePressView;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 mus_window->SetBounds(end_bounds); 515 mus_window->SetBounds(end_bounds);
516 516
517 EXPECT_EQ(end_bounds, mus_window->bounds()); 517 EXPECT_EQ(end_bounds, mus_window->bounds());
518 518
519 // Main check for this test: Setting |mus_window| bounds while bypassing 519 // Main check for this test: Setting |mus_window| bounds while bypassing
520 // |native_widget| must update window_tree_host bounds. 520 // |native_widget| must update window_tree_host bounds.
521 EXPECT_EQ(end_bounds, native_widget->window_tree_host()->GetBounds()); 521 EXPECT_EQ(end_bounds, native_widget->window_tree_host()->GetBounds());
522 } 522 }
523 523
524 } // namespace views 524 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.cc ('k') | ui/views/mus/surface_binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698