Index: ui/views/controls/scroll_view_unittest.cc |
diff --git a/ui/views/controls/scroll_view_unittest.cc b/ui/views/controls/scroll_view_unittest.cc |
index 9a9b002ff84e39b2c01d718c9a8c14c90ba13f7b..6b119f547fe0b9c37bbebc94df6f42fecc53308a 100644 |
--- a/ui/views/controls/scroll_view_unittest.cc |
+++ b/ui/views/controls/scroll_view_unittest.cc |
@@ -8,6 +8,7 @@ |
#include "base/run_loop.h" |
#include "base/test/test_timeouts.h" |
#include "base/threading/thread_task_runner_handle.h" |
+#include "base/tuple.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/views/border.h" |
#include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" |
@@ -21,6 +22,40 @@ |
#include "ui/base/test/scoped_preferred_scroller_style_mac.h" |
#endif |
+namespace base { |
+namespace internal { |
+ |
+template <typename... Args> |
+struct EmplaceUniqueResult { |
+ using Tuple = std::tuple<Args...>; |
+ Tuple params; |
+ |
+ EmplaceUniqueResult(Args&&... args) |
+ : params(std::forward<Args...>(args...)) {} |
+ |
+ template <class T, std::size_t... I> |
+ T* CreateNewT(IndexSequence<I...>) { |
+ return new T(std::get<I>(params)...); |
+ } |
+ |
+ template <class T> |
+ using UniquePtr = std::unique_ptr<T>; // Avoids a presumbmit error. |
+ |
+ template <class T> |
+ operator UniquePtr<T>() { |
+ return UniquePtr<T>(CreateNewT<T>(MakeIndexSequenceForTuple<Tuple>())); |
+ } |
+}; |
+ |
+} // namespace internal |
+ |
+template <typename... Args> |
+typename internal::EmplaceUniqueResult<Args...> EmplaceUnique(Args&&... args) { |
+ return internal::EmplaceUniqueResult<Args...>(std::forward<Args...>(args...)); |
+} |
+ |
+} // namespace base |
+ |
enum ScrollBarOrientation { HORIZONTAL, VERTICAL }; |
namespace views { |
@@ -151,8 +186,7 @@ class ScrollViewTest : public testing::Test { |
// Ensure the old scroller override is destroyed before creating a new one. |
// Otherwise, the swizzlers are interleaved and restore incorrect methods. |
scroller_style_.reset(); |
- scroller_style_ = |
- base::MakeUnique<ui::test::ScopedPreferredScrollerStyle>(enabled); |
+ scroller_style_ = base::EmplaceUnique(enabled); |
} |
private: |