| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/ui/ws/platform_display_default.h" | 5 #include "services/ui/ws/platform_display_default.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "services/ui/common/image_cursors_set.h" |
| 9 #include "services/ui/ws/threaded_image_cursors.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/base/cursor/image_cursors.h" | |
| 10 #include "ui/display/types/native_display_delegate.h" | 11 #include "ui/display/types/native_display_delegate.h" |
| 11 #include "ui/events/event.h" | 12 #include "ui/events/event.h" |
| 12 #include "ui/events/event_sink.h" | 13 #include "ui/events/event_sink.h" |
| 13 #include "ui/gfx/geometry/point.h" | 14 #include "ui/gfx/geometry/point.h" |
| 14 #include "ui/ozone/public/ozone_platform.h" | 15 #include "ui/ozone/public/ozone_platform.h" |
| 15 #include "ui/ozone/public/system_input_injector.h" | 16 #include "ui/ozone/public/system_input_injector.h" |
| 16 #include "ui/platform_window/platform_window.h" | 17 #include "ui/platform_window/platform_window.h" |
| 17 #include "ui/platform_window/stub/stub_window.h" | 18 #include "ui/platform_window/stub/stub_window.h" |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 DISALLOW_COPY_AND_ASSIGN(TestOzonePlatform); | 100 DISALLOW_COPY_AND_ASSIGN(TestOzonePlatform); |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 // Test fails in part because services_unittests appears to have its own ozone | 103 // Test fails in part because services_unittests appears to have its own ozone |
| 103 // platform that it initializes. For some reason, this only started failing | 104 // platform that it initializes. For some reason, this only started failing |
| 104 // locally and on the trybots on 06/13/2017, while passing when run on the CQ | 105 // locally and on the trybots on 06/13/2017, while passing when run on the CQ |
| 105 // and the builders. crbug.com/732987 | 106 // and the builders. crbug.com/732987 |
| 106 TEST(PlatformDisplayDefaultTest, DISABLED_EventDispatch) { | 107 TEST(PlatformDisplayDefaultTest, DISABLED_EventDispatch) { |
| 108 // ThreadTaskRunnerHandle needed required by ThreadedImageCursors. |
| 109 base::MessageLoop loop; |
| 107 // Setup ozone so the display can be initialized. | 110 // Setup ozone so the display can be initialized. |
| 108 TestOzonePlatform platform; | 111 TestOzonePlatform platform; |
| 109 | 112 |
| 110 // Create the display. | 113 // Create the display. |
| 111 display::ViewportMetrics metrics; | 114 display::ViewportMetrics metrics; |
| 112 metrics.bounds_in_pixels = gfx::Rect(1024, 768); | 115 metrics.bounds_in_pixels = gfx::Rect(1024, 768); |
| 113 metrics.device_scale_factor = 1.f; | 116 metrics.device_scale_factor = 1.f; |
| 114 metrics.ui_scale_factor = 1.f; | 117 metrics.ui_scale_factor = 1.f; |
| 118 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 119 base::ThreadTaskRunnerHandle::Get(); |
| 120 ImageCursorsSet image_cursors_set; |
| 121 std::unique_ptr<ThreadedImageCursors> threaded_image_cursors = |
| 122 base::MakeUnique<ThreadedImageCursors>(task_runner, |
| 123 image_cursors_set.GetWeakPtr()); |
| 115 PlatformDisplayDefault display(nullptr, metrics, | 124 PlatformDisplayDefault display(nullptr, metrics, |
| 116 std::unique_ptr<ImageCursors>()); | 125 std::move(threaded_image_cursors)); |
| 117 | 126 |
| 118 // Initialize the display with a test EventSink so we can sense events. | 127 // Initialize the display with a test EventSink so we can sense events. |
| 119 TestEventSink event_sink; | 128 TestEventSink event_sink; |
| 120 TestPlatformDisplayDelegate delegate(&event_sink, &platform); | 129 TestPlatformDisplayDelegate delegate(&event_sink, &platform); |
| 121 display.Init(&delegate); | 130 display.Init(&delegate); |
| 122 | 131 |
| 123 // Event dispatch is handled at the PlatformWindowDelegate level. | 132 // Event dispatch is handled at the PlatformWindowDelegate level. |
| 124 PlatformWindowDelegate* display_for_dispatch = | 133 PlatformWindowDelegate* display_for_dispatch = |
| 125 static_cast<PlatformWindowDelegate*>(&display); | 134 static_cast<PlatformWindowDelegate*>(&display); |
| 126 | 135 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 148 // Releasing the key dispatches exactly one event. | 157 // Releasing the key dispatches exactly one event. |
| 149 KeyEvent key_released(ET_KEY_RELEASED, VKEY_A, EF_NONE); | 158 KeyEvent key_released(ET_KEY_RELEASED, VKEY_A, EF_NONE); |
| 150 display_for_dispatch->DispatchEvent(&key_released); | 159 display_for_dispatch->DispatchEvent(&key_released); |
| 151 EXPECT_EQ(1, event_sink.count_); | 160 EXPECT_EQ(1, event_sink.count_); |
| 152 EXPECT_EQ(ET_KEY_RELEASED, event_sink.last_event_type_); | 161 EXPECT_EQ(ET_KEY_RELEASED, event_sink.last_event_type_); |
| 153 } | 162 } |
| 154 | 163 |
| 155 } // namespace | 164 } // namespace |
| 156 } // namespace ws | 165 } // namespace ws |
| 157 } // namespace ui | 166 } // namespace ui |
| OLD | NEW |