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

Unified Diff: ui/base/clipboard/clipboard_unittest.cc

Issue 136193002: Add Clipboard::GetSequenceNumber test and fix Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Trim Android changes Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/clipboard_unittest.cc
diff --git a/ui/base/clipboard/clipboard_unittest.cc b/ui/base/clipboard/clipboard_unittest.cc
index 5ddec420e180aae395fca493fa3f42d1a0f77fd6..4f689d8fcf754b8bca24f447287cf8116aceb468 100644
--- a/ui/base/clipboard/clipboard_unittest.cc
+++ b/ui/base/clipboard/clipboard_unittest.cc
@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/pickle.h"
+#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -717,6 +718,34 @@ TEST_F(ClipboardTest, WriteEverything) {
// Passes if we don't crash.
}
+// TODO(dcheng): Fix this test for Android. It's rather involved, since the
+// clipboard change listener is posted to the Java message loop, and spinning
+// that loop from C++ to trigger the callback in the test requires a non-trivial
+// amount of additional work.
+#if !defined(OS_ANDROID)
+// Simple test that the sequence number appears to change when the clipboard is
+// written to.
+// TODO(dcheng): Add a version to test CLIPBOARD_TYPE_SELECTION.
+TEST_F(ClipboardTest, GetSequenceNumber) {
+ const uint64 first_sequence_number =
+ clipboard().GetSequenceNumber(CLIPBOARD_TYPE_COPY_PASTE);
+
+ {
+ ScopedClipboardWriter writer(&clipboard(), CLIPBOARD_TYPE_COPY_PASTE);
+ writer.WriteText(UTF8ToUTF16("World"));
+ }
+
+ // On some platforms, the sequence number is updated by a UI callback so pump
+ // the message loop to make sure we get the notification.
+ base::RunLoop().RunUntilIdle();
+
+ const uint64 second_sequence_number =
+ clipboard().GetSequenceNumber(CLIPBOARD_TYPE_COPY_PASTE);
+
+ EXPECT_NE(first_sequence_number, second_sequence_number);
+}
+#endif
+
#if defined(OS_ANDROID)
// Test that if another application writes some text to the pasteboard the
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698