OLD | NEW |
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 <wayland-server-core.h> | 5 #include <wayland-server-core.h> |
6 #include <xdg-shell-unstable-v5-server-protocol.h> | 6 #include <xdg-shell-unstable-v5-server-protocol.h> |
7 | 7 |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/ozone/platform/wayland/fake_server.h" | 10 #include "ui/ozone/platform/wayland/fake_server.h" |
11 #include "ui/ozone/platform/wayland/wayland_connection.h" | 11 #include "ui/ozone/platform/wayland/wayland_connection.h" |
12 #include "ui/ozone/platform/wayland/wayland_output.h" | 12 #include "ui/ozone/public/ozone_platform_screen_delegate.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 | 15 |
16 class OutputObserver : public WaylandOutput::Observer { | 16 class OutputObserver : public ui::OzonePlatformScreenDelegate { |
17 public: | 17 public: |
18 explicit OutputObserver(const base::Closure& closure) : closure_(closure) {} | 18 explicit OutputObserver(const base::Closure& closure) : closure_(closure) {} |
19 | 19 |
20 void OnOutputReadyForUse() override { | 20 void OnOutputGeometryChanged(int32_t name, const gfx::Rect& rect) override { |
21 if (!closure_.is_null()) | 21 if (!closure_.is_null()) |
22 closure_.Run(); | 22 closure_.Run(); |
23 } | 23 } |
24 | 24 |
25 private: | 25 private: |
26 const base::Closure closure_; | 26 const base::Closure closure_; |
27 }; | 27 }; |
28 | 28 |
29 TEST(WaylandConnectionTest, UseUnstableVersion) { | 29 TEST(WaylandConnectionTest, UseUnstableVersion) { |
30 base::MessageLoopForUI message_loop; | 30 base::MessageLoopForUI message_loop; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 base::MessageLoopForUI message_loop; | 63 base::MessageLoopForUI message_loop; |
64 wl::FakeServer server; | 64 wl::FakeServer server; |
65 ASSERT_TRUE(server.Start()); | 65 ASSERT_TRUE(server.Start()); |
66 server.output()->SetRect(gfx::Rect(0, 0, 800, 600)); | 66 server.output()->SetRect(gfx::Rect(0, 0, 800, 600)); |
67 WaylandConnection connection; | 67 WaylandConnection connection; |
68 ASSERT_TRUE(connection.Initialize()); | 68 ASSERT_TRUE(connection.Initialize()); |
69 connection.StartProcessingEvents(); | 69 connection.StartProcessingEvents(); |
70 | 70 |
71 base::RunLoop run_loop; | 71 base::RunLoop run_loop; |
72 OutputObserver observer(run_loop.QuitClosure()); | 72 OutputObserver observer(run_loop.QuitClosure()); |
73 connection.PrimaryOutput()->SetObserver(&observer); | 73 connection.SetOutputObserver(&observer); |
74 run_loop.Run(); | 74 run_loop.Run(); |
75 | 75 |
76 ASSERT_TRUE(connection.GetOutputList().size() == 1); | 76 ASSERT_TRUE(connection.GetOutputList().size() == 1); |
77 WaylandOutput* output = connection.PrimaryOutput(); | 77 WaylandOutput* output = connection.PrimaryOutput(); |
78 ASSERT_TRUE(output->Geometry().width() == 800); | 78 ASSERT_TRUE(output->Geometry().width() == 800); |
79 ASSERT_TRUE(output->Geometry().height() == 600); | 79 ASSERT_TRUE(output->Geometry().height() == 600); |
80 | 80 |
81 server.Resume(); | 81 server.Resume(); |
82 base::RunLoop().RunUntilIdle(); | 82 base::RunLoop().RunUntilIdle(); |
83 server.Pause(); | 83 server.Pause(); |
84 } | 84 } |
85 | 85 |
86 } // namespace ui | 86 } // namespace ui |
OLD | NEW |