| 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/test/platform_test_helper.h" | 5 #include "ui/views/test/platform_test_helper.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 | 10 |
| 11 namespace views { | 11 namespace views { |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class DefaultPlatformTestHelper : public PlatformTestHelper { | 14 class DefaultPlatformTestHelper : public PlatformTestHelper { |
| 15 public: | 15 public: |
| 16 DefaultPlatformTestHelper() {} | 16 DefaultPlatformTestHelper() {} |
| 17 | 17 |
| 18 ~DefaultPlatformTestHelper() override {} | 18 ~DefaultPlatformTestHelper() override {} |
| 19 | 19 |
| 20 bool IsMus() const override { return false; } |
| 21 |
| 20 private: | 22 private: |
| 21 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformTestHelper); | 23 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformTestHelper); |
| 22 }; | 24 }; |
| 23 | 25 |
| 24 PlatformTestHelper::Factory test_helper_factory; | 26 PlatformTestHelper::Factory test_helper_factory; |
| 25 bool is_mus = false; | |
| 26 | 27 |
| 27 } // namespace | 28 } // namespace |
| 28 | 29 |
| 29 void PlatformTestHelper::set_factory(const Factory& factory) { | 30 void PlatformTestHelper::set_factory(const Factory& factory) { |
| 30 DCHECK(test_helper_factory.is_null()); | 31 DCHECK(test_helper_factory.is_null()); |
| 31 test_helper_factory = factory; | 32 test_helper_factory = factory; |
| 32 } | 33 } |
| 33 | 34 |
| 34 // static | 35 // static |
| 35 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { | 36 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { |
| 36 return !test_helper_factory.is_null() | 37 return !test_helper_factory.is_null() |
| 37 ? test_helper_factory.Run() | 38 ? test_helper_factory.Run() |
| 38 : base::WrapUnique(new DefaultPlatformTestHelper); | 39 : base::WrapUnique(new DefaultPlatformTestHelper); |
| 39 } | 40 } |
| 40 | 41 |
| 41 // static | |
| 42 void PlatformTestHelper::SetIsMus() { | |
| 43 is_mus = true; | |
| 44 } | |
| 45 | |
| 46 // static | |
| 47 bool PlatformTestHelper::IsMus() { | |
| 48 return is_mus; | |
| 49 } | |
| 50 | |
| 51 } // namespace views | 42 } // namespace views |
| OLD | NEW |