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

Unified Diff: content/public/test/clipboard_write_observer.cc

Issue 12041078: Clear the clipboard closing Incognito window (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Selection clipboard support Created 7 years, 10 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: content/public/test/clipboard_write_observer.cc
diff --git a/content/public/test/clipboard_write_observer.cc b/content/public/test/clipboard_write_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1eaefa8edab1e8dd388215acdbfec0eaeff23ab2
--- /dev/null
+++ b/content/public/test/clipboard_write_observer.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "clipboard_write_observer.h"
+
+#include "content/public/test/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+ClipboardWriteObserver::ClipboardWriteObserver(ui::Clipboard* clipboard,
+ ui::Clipboard::Buffer buffer)
+ : seen_(false),
+ running_(false),
+ buffer_(buffer),
+ clipboard_(clipboard) {
+ clipboard_->AddObserver(this);
+ DCHECK(ui::Clipboard::IsValidBuffer(buffer_));
+}
+
+ClipboardWriteObserver::~ClipboardWriteObserver() {
+ clipboard_->RemoveObserver(this);
+}
+
+void ClipboardWriteObserver::Wait() {
+ if (seen_) return;
+
+ running_ = true;
+ message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_->Run();
+ EXPECT_TRUE(seen_);
+}
+
+void ClipboardWriteObserver::OnWriteObjects(ui::Clipboard::Buffer buffer) {
+ if (buffer != buffer_) return;
+ seen_ = true;
+ if (!running_) return;
+
+ message_loop_runner_->Quit();
+ running_ = false;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698