OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef UI_BASE_TEST_TEST_CLIPBOARD_H_ | 5 #ifndef UI_BASE_TEST_TEST_CLIPBOARD_H_ |
6 #define UI_BASE_TEST_TEST_CLIPBOARD_H_ | 6 #define UI_BASE_TEST_TEST_CLIPBOARD_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "ui/base/clipboard/clipboard.h" | 15 #include "ui/base/clipboard/clipboard.h" |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 | 18 |
19 class TestClipboard : public Clipboard { | 19 class TestClipboard : public Clipboard { |
20 public: | 20 public: |
21 TestClipboard(); | 21 TestClipboard(); |
22 ~TestClipboard() override; | 22 ~TestClipboard() override; |
23 | 23 |
24 // Creates and associates a TestClipboard with the current thread. When no | 24 // Creates and associates a TestClipboard with the current thread. When no |
25 // longer needed, the returned clipboard must be freed by calling | 25 // longer needed, the returned clipboard must be freed by calling |
26 // Clipboard::DestroyClipboardForCurrentThread() on the same thread. | 26 // Clipboard::DestroyClipboardForCurrentThread() on the same thread. |
27 static Clipboard* CreateForCurrentThread(); | 27 static Clipboard* CreateForCurrentThread(); |
28 | 28 |
| 29 // Sets the time to be returned by GetClipboardLastModifiedTime(); |
| 30 void SetClipboardLastModifiedTime(const base::Time& time); |
| 31 |
29 // Clipboard overrides. | 32 // Clipboard overrides. |
30 void OnPreShutdown() override; | 33 void OnPreShutdown() override; |
31 uint64_t GetSequenceNumber(ClipboardType type) const override; | 34 uint64_t GetSequenceNumber(ClipboardType type) const override; |
32 bool IsFormatAvailable(const FormatType& format, | 35 bool IsFormatAvailable(const FormatType& format, |
33 ClipboardType type) const override; | 36 ClipboardType type) const override; |
34 void Clear(ClipboardType type) override; | 37 void Clear(ClipboardType type) override; |
35 void ReadAvailableTypes(ClipboardType type, | 38 void ReadAvailableTypes(ClipboardType type, |
36 std::vector<base::string16>* types, | 39 std::vector<base::string16>* types, |
37 bool* contains_filenames) const override; | 40 bool* contains_filenames) const override; |
38 void ReadText(ClipboardType type, base::string16* result) const override; | 41 void ReadText(ClipboardType type, base::string16* result) const override; |
39 void ReadAsciiText(ClipboardType type, std::string* result) const override; | 42 void ReadAsciiText(ClipboardType type, std::string* result) const override; |
40 void ReadHTML(ClipboardType type, | 43 void ReadHTML(ClipboardType type, |
41 base::string16* markup, | 44 base::string16* markup, |
42 std::string* src_url, | 45 std::string* src_url, |
43 uint32_t* fragment_start, | 46 uint32_t* fragment_start, |
44 uint32_t* fragment_end) const override; | 47 uint32_t* fragment_end) const override; |
45 void ReadRTF(ClipboardType type, std::string* result) const override; | 48 void ReadRTF(ClipboardType type, std::string* result) const override; |
46 SkBitmap ReadImage(ClipboardType type) const override; | 49 SkBitmap ReadImage(ClipboardType type) const override; |
47 void ReadCustomData(ClipboardType clipboard_type, | 50 void ReadCustomData(ClipboardType clipboard_type, |
48 const base::string16& type, | 51 const base::string16& type, |
49 base::string16* result) const override; | 52 base::string16* result) const override; |
50 void ReadBookmark(base::string16* title, std::string* url) const override; | 53 void ReadBookmark(base::string16* title, std::string* url) const override; |
51 void ReadData(const FormatType& format, std::string* result) const override; | 54 void ReadData(const FormatType& format, std::string* result) const override; |
| 55 base::Time GetClipboardLastModifiedTime() const override; |
52 void WriteObjects(ClipboardType type, const ObjectMap& objects) override; | 56 void WriteObjects(ClipboardType type, const ObjectMap& objects) override; |
53 void WriteText(const char* text_data, size_t text_len) override; | 57 void WriteText(const char* text_data, size_t text_len) override; |
54 void WriteHTML(const char* markup_data, | 58 void WriteHTML(const char* markup_data, |
55 size_t markup_len, | 59 size_t markup_len, |
56 const char* url_data, | 60 const char* url_data, |
57 size_t url_len) override; | 61 size_t url_len) override; |
58 void WriteRTF(const char* rtf_data, size_t data_len) override; | 62 void WriteRTF(const char* rtf_data, size_t data_len) override; |
59 void WriteBookmark(const char* title_data, | 63 void WriteBookmark(const char* title_data, |
60 size_t title_len, | 64 size_t title_len, |
61 const char* url_data, | 65 const char* url_data, |
(...skipping 18 matching lines...) Expand all Loading... |
80 }; | 84 }; |
81 | 85 |
82 // The non-const versions increment the sequence number as a side effect. | 86 // The non-const versions increment the sequence number as a side effect. |
83 const DataStore& GetStore(ClipboardType type) const; | 87 const DataStore& GetStore(ClipboardType type) const; |
84 const DataStore& GetDefaultStore() const; | 88 const DataStore& GetDefaultStore() const; |
85 DataStore& GetStore(ClipboardType type); | 89 DataStore& GetStore(ClipboardType type); |
86 DataStore& GetDefaultStore(); | 90 DataStore& GetDefaultStore(); |
87 | 91 |
88 ClipboardType default_store_type_; | 92 ClipboardType default_store_type_; |
89 mutable std::map<ClipboardType, DataStore> stores_; | 93 mutable std::map<ClipboardType, DataStore> stores_; |
| 94 base::Time last_modified_time_; |
90 | 95 |
91 DISALLOW_COPY_AND_ASSIGN(TestClipboard); | 96 DISALLOW_COPY_AND_ASSIGN(TestClipboard); |
92 }; | 97 }; |
93 | 98 |
94 } // namespace ui | 99 } // namespace ui |
95 | 100 |
96 #endif // UI_BASE_TEST_TEST_CLIPBOARD_H_ | 101 #endif // UI_BASE_TEST_TEST_CLIPBOARD_H_ |
OLD | NEW |