| 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/aura/mus/os_exchange_data_provider_mus.h" | 5 #include "ui/aura/mus/os_exchange_data_provider_mus.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 class OSExchangeDataProviderMusTest | 33 class OSExchangeDataProviderMusTest |
| 34 : public PlatformTest, | 34 : public PlatformTest, |
| 35 public ui::OSExchangeDataProviderFactory::Factory { | 35 public ui::OSExchangeDataProviderFactory::Factory { |
| 36 public: | 36 public: |
| 37 OSExchangeDataProviderMusTest() {} | 37 OSExchangeDataProviderMusTest() {} |
| 38 | 38 |
| 39 // Overridden from PlatformTest: | 39 // Overridden from PlatformTest: |
| 40 void SetUp() override { | 40 void SetUp() override { |
| 41 PlatformTest::SetUp(); | 41 PlatformTest::SetUp(); |
| 42 old_factory_ = ui::OSExchangeDataProviderFactory::TakeFactory(); |
| 42 ui::OSExchangeDataProviderFactory::SetFactory(this); | 43 ui::OSExchangeDataProviderFactory::SetFactory(this); |
| 43 } | 44 } |
| 44 | 45 |
| 45 void TearDown() override { | 46 void TearDown() override { |
| 46 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); | 47 ui::OSExchangeDataProviderFactory::TakeFactory(); |
| 48 ui::OSExchangeDataProviderFactory::SetFactory(old_factory_); |
| 47 PlatformTest::TearDown(); | 49 PlatformTest::TearDown(); |
| 48 } | 50 } |
| 49 | 51 |
| 50 // Overridden from ui::OSExchangeDataProviderFactory::Factory: | 52 // Overridden from ui::OSExchangeDataProviderFactory::Factory: |
| 51 std::unique_ptr<OSExchangeData::Provider> BuildProvider() override { | 53 std::unique_ptr<OSExchangeData::Provider> BuildProvider() override { |
| 52 return base::MakeUnique<OSExchangeDataProviderMus>(); | 54 return base::MakeUnique<OSExchangeDataProviderMus>(); |
| 53 } | 55 } |
| 54 | 56 |
| 55 private: | 57 private: |
| 58 ui::OSExchangeDataProviderFactory::Factory* old_factory_ = nullptr; |
| 56 base::MessageLoopForUI message_loop_; | 59 base::MessageLoopForUI message_loop_; |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 TEST_F(OSExchangeDataProviderMusTest, StringDataGetAndSet) { | 62 TEST_F(OSExchangeDataProviderMusTest, StringDataGetAndSet) { |
| 60 OSExchangeData data; | 63 OSExchangeData data; |
| 61 base::string16 input = base::ASCIIToUTF16("I can has cheezburger?"); | 64 base::string16 input = base::ASCIIToUTF16("I can has cheezburger?"); |
| 62 EXPECT_FALSE(data.HasString()); | 65 EXPECT_FALSE(data.HasString()); |
| 63 data.SetString(input); | 66 data.SetString(input); |
| 64 EXPECT_TRUE(data.HasString()); | 67 EXPECT_TRUE(data.HasString()); |
| 65 | 68 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 data.SetHtml(html, url); | 203 data.SetHtml(html, url); |
| 201 | 204 |
| 202 OSExchangeData copy( | 205 OSExchangeData copy( |
| 203 std::unique_ptr<OSExchangeData::Provider>(data.provider().Clone())); | 206 std::unique_ptr<OSExchangeData::Provider>(data.provider().Clone())); |
| 204 base::string16 read_html; | 207 base::string16 read_html; |
| 205 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); | 208 EXPECT_TRUE(copy.GetHtml(&read_html, &url)); |
| 206 EXPECT_EQ(html, read_html); | 209 EXPECT_EQ(html, read_html); |
| 207 } | 210 } |
| 208 | 211 |
| 209 } // namespace aura | 212 } // namespace aura |
| OLD | NEW |