Chromium Code Reviews| Index: ui/base/clipboard/clipboard_android_unittest.cc |
| diff --git a/ui/base/clipboard/clipboard_android_unittest.cc b/ui/base/clipboard/clipboard_android_unittest.cc |
| index d52013d4bcbe3bb9dac6a34450e025994956279c..fd4fb332dff91b13d1a10227df1cbf3b332cd176 100644 |
| --- a/ui/base/clipboard/clipboard_android_unittest.cc |
| +++ b/ui/base/clipboard/clipboard_android_unittest.cc |
| @@ -4,9 +4,12 @@ |
| #include "ui/base/clipboard/clipboard_android.h" |
| +#include <string> |
| + |
| #include "base/android/context_utils.h" |
| #include "base/android/jni_android.h" |
| #include "base/android/jni_string.h" |
| +#include "base/time/time.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| @@ -85,6 +88,34 @@ TEST_F(ClipboardAndroidTest, InternalClipboardInvalidation) { |
| EXPECT_EQ(contents, new_value); |
| } |
| +TEST_F(ClipboardAndroidTest, LastModifiedTimePersists) { |
| + // Set up the pref system. *** |
|
Bernhard Bauer
2017/04/25 13:30:06
Super-nit: The asterisks look a bit out of place..
Mark P
2017/04/25 18:51:21
Moot. I've removed this test from the changelist
|
| + // 1. Create a TestingPrefServiceSimple (which is a PrefService) |
| + // and also use is registry() function. |
| + // 2. Call ClipboardAndroid::RegisterPrefs() |
| + // 3. Call ClipboardAndroid::SetLocalState() |
| + |
| + base::Time test_start_time = base::Time::Now(); |
| + std::string url = "http://example.com/"; |
| + clipboard().WriteText(url.data(), url.length()); |
| + base::TimeDelta last_modified_time = clipboard().GetLastModifiedTime(); |
| + // It's possible the WriteText() took some time, so allow a little slop |
| + // (5 seconds) in this comparison; don't check for equality. |
| + EXPECT_GE(last_modified_time, test_start_time); |
| + EXPECT_LE(last_modified_time, |
| + test_start_time + base::TimeDelta::FromSeconds(5)); |
| + |
| + // *** Force writing the prefs / storing them, if necessary. |
| + |
| + // Destroy the clipboard and make sure the information persists. (It's be |
| + // implicitly recreated when accessed.) |
| + Clipboard::DestroyClipboardForCurrentThread(); |
| + |
| + // *** |
| + // Check that the last modified time hasn't changed from the last time |
| + // we read it. |
|
Bernhard Bauer
2017/04/25 13:30:06
Is that still coming? :)
Mark P
2017/04/25 18:51:21
No. :-P See above.
|
| +} |
| + |
| } // namespace ui |
| #include "ui/base/clipboard/clipboard_test_template.h" |