Chromium Code Reviews| Index: ui/views/mus/clipboard_unittest.cc |
| diff --git a/ui/views/mus/clipboard_unittest.cc b/ui/views/mus/clipboard_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..63de6bb2b671ec07d095d09fa23f3a9eed293995 |
| --- /dev/null |
| +++ b/ui/views/mus/clipboard_unittest.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/views/mus/clipboard_mus.h" |
| + |
| +#include "base/message_loop/message_loop.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "ui/events/platform/platform_event_source.h" |
| +#include "ui/views/mus/window_manager_connection.h" |
| +#include "ui/views/test/scoped_views_test_helper.h" |
| + |
| +namespace ui { |
| + |
| +struct PlatformClipboardTraits { |
| + static std::unique_ptr<PlatformEventSource> GetEventSource() { |
| + return std::unique_ptr<PlatformEventSource>(); |
|
dcheng
2016/06/04 06:14:00
Nit: nullptr
|
| + } |
| + |
| + static Clipboard* Create() { |
| + EXPECT_FALSE(test_helper.get()); |
|
dcheng
2016/06/04 06:14:01
Nit: EXPECT_FALSE(test_helper)
|
| + |
| + // We need to set up enough of views so that it reaches out to mus for a |
| + // window manager connection. |
| + test_helper.reset(new views::ScopedViewsTestHelper); |
| + |
| + // If we don't have a window manager connection, we will get the default |
| + // platform clipboard instead. |
| + EXPECT_TRUE(views::WindowManagerConnection::Exists()); |
| + |
| + return Clipboard::GetForCurrentThread(); |
| + } |
| + |
| + static bool IsMusTest() { return true; } |
| + |
| + static void Destroy(Clipboard* clipboard) { |
| + ASSERT_EQ(Clipboard::GetForCurrentThread(), clipboard); |
| + Clipboard::DestroyClipboardForCurrentThread(); |
| + |
| + test_helper.reset(); |
| + } |
| + |
| + static std::unique_ptr<views::ScopedViewsTestHelper> test_helper; |
| +}; |
| + |
| +std::unique_ptr<views::ScopedViewsTestHelper> |
| + PlatformClipboardTraits::test_helper; |
|
dcheng
2016/06/04 06:14:00
I don't think we allow globals of non-POD type.
Elliot Glaysher
2016/06/06 20:10:12
In chrome code. This is in a unit test.
I also do
dcheng
2016/06/07 05:39:00
I don't think the style guide distinguishes betwee
Elliot Glaysher
2016/06/07 17:16:19
Replaced static with a forwarding subclass of ui::
|
| + |
| +typedef PlatformClipboardTraits TypesToTest; |
|
dcheng
2016/06/04 06:14:00
Nit: using (I guess this is copying the pattern in
|
| + |
| +} // namespace ui |
| + |
| +#include "ui/base/clipboard/clipboard_test_template.h" |