Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: ui/base/test/test_clipboard.cc

Issue 1162373002: Make some editing/selection functions accessible to c/b/renderer_host/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switched to oninput event as oncut/onpaste happen before cut/paste Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ba37cdaf2c6c8154edec03617b18f2f1203a16f9 100644
--- a/ui/base/test/test_clipboard.cc
+++ b/ui/base/test/test_clipboard.cc
@@ -5,13 +5,18 @@
#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() {
@@ -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) {
}

Powered by Google App Engine
This is Rietveld 408576698