OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Note: This header doesn't use REGISTER_TYPED_TEST_CASE_P like most | 5 // Note: This header doesn't use REGISTER_TYPED_TEST_CASE_P like most |
6 // type-parameterized gtests. There are lot of test cases in here that are only | 6 // type-parameterized gtests. There are lot of test cases in here that are only |
7 // enabled on certain platforms. However, preprocessor directives in macro | 7 // enabled on certain platforms. However, preprocessor directives in macro |
8 // arguments result in undefined behavior (and don't work on MSVC). Instead, | 8 // arguments result in undefined behavior (and don't work on MSVC). Instead, |
9 // 'parameterized' tests should typedef TypesToTest (which is used to | 9 // 'parameterized' tests should typedef TypesToTest (which is used to |
10 // instantiate the tests using the TYPED_TEST_CASE macro) and then #include this | 10 // instantiate the tests using the TYPED_TEST_CASE macro) and then #include this |
11 // header. | 11 // header. |
12 // TODO(dcheng): This is really horrible. In general, all tests should run on | 12 // TODO(dcheng): This is really horrible. In general, all tests should run on |
13 // all platforms, to avoid this mess. | 13 // all platforms, to avoid this mess. |
14 | 14 |
15 #include "build/build_config.h" | |
16 | |
17 #include <stdint.h> | 15 #include <stdint.h> |
18 | 16 |
| 17 #include <memory> |
19 #include <string> | 18 #include <string> |
20 | 19 |
21 #include "base/memory/scoped_ptr.h" | |
22 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
23 #include "base/pickle.h" | 21 #include "base/pickle.h" |
24 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
25 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
26 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 25 #include "build/build_config.h" |
27 #include "testing/gmock/include/gmock/gmock-matchers.h" | 26 #include "testing/gmock/include/gmock/gmock-matchers.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
29 #include "testing/platform_test.h" | 28 #include "testing/platform_test.h" |
30 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
31 #include "third_party/skia/include/core/SkColor.h" | 30 #include "third_party/skia/include/core/SkColor.h" |
32 #include "third_party/skia/include/core/SkScalar.h" | 31 #include "third_party/skia/include/core/SkScalar.h" |
33 #include "third_party/skia/include/core/SkUnPreMultiply.h" | 32 #include "third_party/skia/include/core/SkUnPreMultiply.h" |
34 #include "ui/base/clipboard/clipboard.h" | 33 #include "ui/base/clipboard/clipboard.h" |
35 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 34 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
36 #include "ui/base/test/test_clipboard.h" | 35 #include "ui/base/test/test_clipboard.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 std::vector<base::string16> GetAvailableTypes(ClipboardType type) { | 70 std::vector<base::string16> GetAvailableTypes(ClipboardType type) { |
72 bool contains_filenames; | 71 bool contains_filenames; |
73 std::vector<base::string16> types; | 72 std::vector<base::string16> types; |
74 clipboard().ReadAvailableTypes(type, &types, &contains_filenames); | 73 clipboard().ReadAvailableTypes(type, &types, &contains_filenames); |
75 return types; | 74 return types; |
76 } | 75 } |
77 | 76 |
78 private: | 77 private: |
79 base::MessageLoopForUI message_loop_; | 78 base::MessageLoopForUI message_loop_; |
80 #if defined(USE_AURA) | 79 #if defined(USE_AURA) |
81 scoped_ptr<PlatformEventSource> event_source_; | 80 std::unique_ptr<PlatformEventSource> event_source_; |
82 #endif | 81 #endif |
83 // ui::Clipboard has a protected destructor, so scoped_ptr doesn't work here. | 82 // ui::Clipboard has a protected destructor, so scoped_ptr doesn't work here. |
84 Clipboard* const clipboard_; | 83 Clipboard* const clipboard_; |
85 }; | 84 }; |
86 | 85 |
87 // Hack for tests that need to call static methods of ClipboardTest. | 86 // Hack for tests that need to call static methods of ClipboardTest. |
88 struct NullClipboardTraits { | 87 struct NullClipboardTraits { |
89 static Clipboard* Create() { return nullptr; } | 88 static Clipboard* Create() { return nullptr; } |
90 static void Destroy(Clipboard*) {} | 89 static void Destroy(Clipboard*) {} |
91 }; | 90 }; |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 ScopedClipboardWriter scw(CLIPBOARD_TYPE_COPY_PASTE); | 670 ScopedClipboardWriter scw(CLIPBOARD_TYPE_COPY_PASTE); |
672 scw.WritePickledData(base::Pickle(), Clipboard::GetPlainTextFormatType()); | 671 scw.WritePickledData(base::Pickle(), Clipboard::GetPlainTextFormatType()); |
673 } | 672 } |
674 | 673 |
675 TYPED_TEST(ClipboardTest, WriteImageEmptyParams) { | 674 TYPED_TEST(ClipboardTest, WriteImageEmptyParams) { |
676 ScopedClipboardWriter scw(CLIPBOARD_TYPE_COPY_PASTE); | 675 ScopedClipboardWriter scw(CLIPBOARD_TYPE_COPY_PASTE); |
677 scw.WriteImage(SkBitmap()); | 676 scw.WriteImage(SkBitmap()); |
678 } | 677 } |
679 | 678 |
680 } // namespace ui | 679 } // namespace ui |
OLD | NEW |