| Index: ui/base/test/test_clipboard.cc
|
| diff --git a/ui/base/test/test_clipboard.cc b/ui/base/test/test_clipboard.cc
|
| index cbea7e850c2869087f94c02726f2f190e8d71a47..6470931fa5b349bdd2e2feff972cc7a4811e02aa 100644
|
| --- a/ui/base/test/test_clipboard.cc
|
| +++ b/ui/base/test/test_clipboard.cc
|
| @@ -5,21 +5,26 @@
|
| #include "ui/base/test/test_clipboard.h"
|
|
|
| #include <stddef.h>
|
| +
|
| +#include "base/auto_reset.h"
|
| #include "base/numerics/safe_conversions.h"
|
| +#include "base/run_loop.h"
|
| #include "base/strings/utf_string_conversions.h"
|
|
|
| namespace ui {
|
|
|
| TestClipboard::TestClipboard()
|
| - : default_store_type_(CLIPBOARD_TYPE_COPY_PASTE) {
|
| + : default_store_type_(CLIPBOARD_TYPE_COPY_PASTE),
|
| + waiting_for_write_text_(false),
|
| + write_text_called_(false) {
|
| }
|
|
|
| TestClipboard::~TestClipboard() {
|
| }
|
|
|
| -Clipboard* TestClipboard::CreateForCurrentThread() {
|
| +TestClipboard* TestClipboard::CreateForCurrentThread() {
|
| base::AutoLock lock(Clipboard::clipboard_map_lock_.Get());
|
| - Clipboard* clipboard = new TestClipboard;
|
| + TestClipboard* clipboard = new TestClipboard;
|
| Clipboard::clipboard_map_.Get()[base::PlatformThread::CurrentId()] =
|
| clipboard;
|
| return clipboard;
|
| @@ -125,6 +130,12 @@ void TestClipboard::WriteText(const char* text_data, size_t text_len) {
|
| GetDefaultStore().data[GetPlainTextWFormatType()];
|
| if (IsSupportedClipboardType(CLIPBOARD_TYPE_SELECTION))
|
| GetStore(CLIPBOARD_TYPE_SELECTION).data[GetPlainTextFormatType()] = text;
|
| +
|
| + write_text_called_ = true;
|
| + if (waiting_for_write_text_) {
|
| + waiting_for_write_text_ = false;
|
| + write_text_wait_quit_closure_.Run();
|
| + }
|
| }
|
|
|
| void TestClipboard::WriteHTML(const char* markup_data,
|
| @@ -166,6 +177,23 @@ void TestClipboard::WriteData(const FormatType& format,
|
| GetDefaultStore().data[format] = std::string(data_data, data_len);
|
| }
|
|
|
| +void TestClipboard::ResetWaits() {
|
| + waiting_for_write_text_ = false;
|
| + write_text_called_ = false;
|
| +}
|
| +
|
| +void TestClipboard::WaitForWriteText() {
|
| + DCHECK(!waiting_for_write_text_);
|
| + if (write_text_called_)
|
| + return;
|
| + base::RunLoop run_loop;
|
| + base::AutoReset<base::Closure> reset_quit_closure(
|
| + &write_text_wait_quit_closure_, run_loop.QuitClosure());
|
| + base::AutoReset<bool> reset_waiting_for_write_text_(&waiting_for_write_text_,
|
| + true);
|
| + run_loop.Run();
|
| +}
|
| +
|
| TestClipboard::DataStore::DataStore() : sequence_number(0) {
|
| }
|
|
|
|
|