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 <map> | 8 #include <map> |
| 9 #include "base/callback.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "ui/base/clipboard/clipboard.h" | 11 #include "ui/base/clipboard/clipboard.h" |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 | 14 |
14 class TestClipboard : public Clipboard { | 15 class TestClipboard : public Clipboard { |
15 public: | 16 public: |
16 TestClipboard(); | 17 TestClipboard(); |
17 ~TestClipboard() override; | 18 ~TestClipboard() override; |
18 | 19 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void WriteBookmark(const char* title_data, | 54 void WriteBookmark(const char* title_data, |
54 size_t title_len, | 55 size_t title_len, |
55 const char* url_data, | 56 const char* url_data, |
56 size_t url_len) override; | 57 size_t url_len) override; |
57 void WriteWebSmartPaste() override; | 58 void WriteWebSmartPaste() override; |
58 void WriteBitmap(const SkBitmap& bitmap) override; | 59 void WriteBitmap(const SkBitmap& bitmap) override; |
59 void WriteData(const FormatType& format, | 60 void WriteData(const FormatType& format, |
60 const char* data_data, | 61 const char* data_data, |
61 size_t data_len) override; | 62 size_t data_len) override; |
62 | 63 |
| 64 void ResetWaits(); |
| 65 void WaitForWriteText(); |
| 66 |
63 private: | 67 private: |
64 struct DataStore { | 68 struct DataStore { |
65 DataStore(); | 69 DataStore(); |
66 ~DataStore(); | 70 ~DataStore(); |
67 void Clear(); | 71 void Clear(); |
68 uint64 sequence_number; | 72 uint64 sequence_number; |
69 std::map<FormatType, std::string> data; | 73 std::map<FormatType, std::string> data; |
70 std::string url_title; | 74 std::string url_title; |
71 std::string html_src_url; | 75 std::string html_src_url; |
72 SkBitmap image; | 76 SkBitmap image; |
73 }; | 77 }; |
74 | 78 |
75 // The non-const versions increment the sequence number as a side effect. | 79 // The non-const versions increment the sequence number as a side effect. |
76 const DataStore& GetStore(ClipboardType type) const; | 80 const DataStore& GetStore(ClipboardType type) const; |
77 const DataStore& GetDefaultStore() const; | 81 const DataStore& GetDefaultStore() const; |
78 DataStore& GetStore(ClipboardType type); | 82 DataStore& GetStore(ClipboardType type); |
79 DataStore& GetDefaultStore(); | 83 DataStore& GetDefaultStore(); |
80 | 84 |
81 ClipboardType default_store_type_; | 85 ClipboardType default_store_type_; |
82 mutable std::map<ClipboardType, DataStore> stores_; | 86 mutable std::map<ClipboardType, DataStore> stores_; |
83 | 87 |
| 88 bool waiting_for_write_text_; |
| 89 bool write_text_called_; |
| 90 base::Closure write_text_wait_quit_closure_; |
| 91 |
84 DISALLOW_COPY_AND_ASSIGN(TestClipboard); | 92 DISALLOW_COPY_AND_ASSIGN(TestClipboard); |
85 }; | 93 }; |
86 | 94 |
87 } // namespace ui | 95 } // namespace ui |
88 | 96 |
89 #endif // UI_BASE_TEST_TEST_CLIPBOARD_H_ | 97 #endif // UI_BASE_TEST_TEST_CLIPBOARD_H_ |
OLD | NEW |