| Index: ui/views/mus/os_exchange_data_provider_mus_unittest.cc
|
| diff --git a/ui/base/dragdrop/os_exchange_data_unittest.cc b/ui/views/mus/os_exchange_data_provider_mus_unittest.cc
|
| similarity index 78%
|
| copy from ui/base/dragdrop/os_exchange_data_unittest.cc
|
| copy to ui/views/mus/os_exchange_data_provider_mus_unittest.cc
|
| index b1425f161efefbb186ff30a7a0f9075b02838cb2..c2a7644dd9616207229888a09c48f2082df1b38d 100644
|
| --- a/ui/base/dragdrop/os_exchange_data_unittest.cc
|
| +++ b/ui/views/mus/os_exchange_data_provider_mus_unittest.cc
|
| @@ -1,10 +1,11 @@
|
| -// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// 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 <memory>
|
|
|
| #include "base/files/file_util.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/pickle.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| @@ -13,22 +14,48 @@
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "testing/platform_test.h"
|
| #include "ui/base/dragdrop/os_exchange_data.h"
|
| +#include "ui/base/dragdrop/os_exchange_data_provider_factory.h"
|
| #include "ui/events/platform/platform_event_source.h"
|
| +#include "ui/views/mus/os_exchange_data_provider_mus.h"
|
| #include "url/gurl.h"
|
|
|
| -namespace ui {
|
| +using ui::Clipboard;
|
| +using ui::OSExchangeData;
|
|
|
| -class OSExchangeDataTest : public PlatformTest {
|
| +namespace views {
|
| +
|
| +// This file is a copy/paste of the unit tests in os_exchange_data_unittest.cc,
|
| +// with additional SetUp() to force the mus override. I thought about changeing
|
| +// the OSExchangeData test suite to a parameterized test suite, but I've
|
| +// previously had problems with that feature of gtest.
|
| +
|
| +class OSExchangeDataProviderMusTest
|
| + : public PlatformTest,
|
| + public ui::OSExchangeDataProviderFactory::Factory {
|
| public:
|
| - OSExchangeDataTest()
|
| - : event_source_(ui::PlatformEventSource::CreateDefault()) {}
|
| + OSExchangeDataProviderMusTest() {}
|
| +
|
| + // Overridden from PlatformTest:
|
| + void SetUp() override {
|
| + PlatformTest::SetUp();
|
| + ui::OSExchangeDataProviderFactory::SetFactory(this);
|
| + }
|
| +
|
| + void TearDown() override {
|
| + ui::OSExchangeDataProviderFactory::SetFactory(nullptr);
|
| + PlatformTest::TearDown();
|
| + }
|
| +
|
| + // Overridden from ui::OSExchangeDataProviderFactory::Factory:
|
| + std::unique_ptr<OSExchangeData::Provider> BuildProvider() override {
|
| + return base::MakeUnique<OSExchangeDataProviderMus>();
|
| + }
|
|
|
| private:
|
| base::MessageLoopForUI message_loop_;
|
| - std::unique_ptr<PlatformEventSource> event_source_;
|
| };
|
|
|
| -TEST_F(OSExchangeDataTest, StringDataGetAndSet) {
|
| +TEST_F(OSExchangeDataProviderMusTest, StringDataGetAndSet) {
|
| OSExchangeData data;
|
| base::string16 input = base::ASCIIToUTF16("I can has cheezburger?");
|
| EXPECT_FALSE(data.HasString());
|
| @@ -50,7 +77,7 @@ TEST_F(OSExchangeDataTest, StringDataGetAndSet) {
|
| EXPECT_EQ(url_spec, url.spec());
|
| }
|
|
|
| -TEST_F(OSExchangeDataTest, TestURLExchangeFormats) {
|
| +TEST_F(OSExchangeDataProviderMusTest, TestURLExchangeFormats) {
|
| OSExchangeData data;
|
| std::string url_spec = "http://www.google.com/";
|
| GURL url(url_spec);
|
| @@ -78,7 +105,7 @@ TEST_F(OSExchangeDataTest, TestURLExchangeFormats) {
|
| }
|
|
|
| // Test that setting the URL does not overwrite a previously set custom string.
|
| -TEST_F(OSExchangeDataTest, URLAndString) {
|
| +TEST_F(OSExchangeDataProviderMusTest, URLAndString) {
|
| OSExchangeData data;
|
| base::string16 string = base::ASCIIToUTF16("I can has cheezburger?");
|
| data.SetString(string);
|
| @@ -99,7 +126,7 @@ TEST_F(OSExchangeDataTest, URLAndString) {
|
| EXPECT_EQ(url_title, output_title);
|
| }
|
|
|
| -TEST_F(OSExchangeDataTest, TestFileToURLConversion) {
|
| +TEST_F(OSExchangeDataProviderMusTest, TestFileToURLConversion) {
|
| OSExchangeData data;
|
| EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
|
| EXPECT_FALSE(data.HasURL(OSExchangeData::CONVERT_FILENAMES));
|
| @@ -138,7 +165,7 @@ TEST_F(OSExchangeDataTest, TestFileToURLConversion) {
|
| EXPECT_EQ(current_directory, actual_path);
|
| }
|
|
|
| -TEST_F(OSExchangeDataTest, TestPickledData) {
|
| +TEST_F(OSExchangeDataProviderMusTest, TestPickledData) {
|
| const Clipboard::FormatType kTestFormat =
|
| Clipboard::GetFormatType("application/vnd.chromium.test");
|
|
|
| @@ -163,7 +190,7 @@ TEST_F(OSExchangeDataTest, TestPickledData) {
|
| }
|
|
|
| #if defined(USE_AURA)
|
| -TEST_F(OSExchangeDataTest, TestHTML) {
|
| +TEST_F(OSExchangeDataProviderMusTest, TestHTML) {
|
| OSExchangeData data;
|
| GURL url("http://www.google.com/");
|
| base::string16 html = base::ASCIIToUTF16(
|
| @@ -180,4 +207,5 @@ TEST_F(OSExchangeDataTest, TestHTML) {
|
| }
|
| #endif
|
|
|
| -} // namespace ui
|
| +} // namespace views
|
| +
|
|
|