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 "ui/views/mus/clipboard_mus.h" | 5 #include "ui/views/mus/clipboard_mus.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/events/platform/platform_event_source.h" | 9 #include "ui/events/platform/platform_event_source.h" |
10 #include "ui/views/mus/window_manager_connection.h" | 10 #include "ui/views/mus/mus_client.h" |
11 #include "ui/views/test/scoped_views_test_helper.h" | 11 #include "ui/views/test/scoped_views_test_helper.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 | 14 |
15 // So we can't make ScopedViewsTestHelper a global. We must set up | 15 // So we can't make ScopedViewsTestHelper a global. We must set up |
16 // ScopedViewsTestHelper on every test (which will create the connection to | 16 // ScopedViewsTestHelper on every test (which will create the connection to |
17 // mus). And we can't modify PlatformClipboardTraits to not be a pure static | 17 // mus). And we can't modify PlatformClipboardTraits to not be a pure static |
18 // struct. So to solve these lifetime issues, create an adapter that owns the | 18 // struct. So to solve these lifetime issues, create an adapter that owns the |
19 // ScopedViewsTestHelper and then . | 19 // ScopedViewsTestHelper and then . |
20 class ForwardingTestingClipboard : public ui::Clipboard { | 20 class ForwardingTestingClipboard : public ui::Clipboard { |
21 public: | 21 public: |
22 ForwardingTestingClipboard() | 22 ForwardingTestingClipboard() |
23 : test_helper_(new views::ScopedViewsTestHelper), | 23 : test_helper_(new views::ScopedViewsTestHelper), |
24 clipboard_to_test_(Clipboard::GetForCurrentThread()) { | 24 clipboard_to_test_(Clipboard::GetForCurrentThread()) { |
25 // If we don't have a window manager connection, we will get the default | 25 // If we don't have a window manager connection, we will get the default |
26 // platform clipboard instead. | 26 // platform clipboard instead. |
27 EXPECT_TRUE(views::WindowManagerConnection::Exists()); | 27 EXPECT_TRUE(views::MusClient::Exists()); |
28 } | 28 } |
29 | 29 |
30 ~ForwardingTestingClipboard() override { | 30 ~ForwardingTestingClipboard() override { |
31 Clipboard::DestroyClipboardForCurrentThread(); | 31 Clipboard::DestroyClipboardForCurrentThread(); |
32 } | 32 } |
33 | 33 |
34 void Destroy() { | 34 void Destroy() { |
35 delete this; | 35 delete this; |
36 } | 36 } |
37 | 37 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 static void Destroy(Clipboard* clipboard) { | 136 static void Destroy(Clipboard* clipboard) { |
137 static_cast<ForwardingTestingClipboard*>(clipboard)->Destroy(); | 137 static_cast<ForwardingTestingClipboard*>(clipboard)->Destroy(); |
138 } | 138 } |
139 }; | 139 }; |
140 | 140 |
141 using TypesToTest = PlatformClipboardTraits; | 141 using TypesToTest = PlatformClipboardTraits; |
142 | 142 |
143 } // namespace ui | 143 } // namespace ui |
144 | 144 |
145 #include "ui/base/clipboard/clipboard_test_template.h" | 145 #include "ui/base/clipboard/clipboard_test_template.h" |
OLD | NEW |