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

Side by Side Diff: ui/base/clipboard/clipboard_android_unittest.cc

Issue 2832263002: Clipboard Android - Store and Read Last Modified Time from Prefs (Closed)
Patch Set: revert omnibox_field_trial_code, rebase Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/clipboard/clipboard_android.h" 5 #include "ui/base/clipboard/clipboard_android.h"
6 6
7 #include <string>
8
7 #include "base/android/context_utils.h" 9 #include "base/android/context_utils.h"
8 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
9 #include "base/android/jni_string.h" 11 #include "base/android/jni_string.h"
12 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/base/clipboard/scoped_clipboard_writer.h" 14 #include "ui/base/clipboard/scoped_clipboard_writer.h"
12 15
13 namespace ui { 16 namespace ui {
14 17
15 class ClipboardAndroidTest : public ::testing::Test { 18 class ClipboardAndroidTest : public ::testing::Test {
16 public: 19 public:
17 ~ClipboardAndroidTest() override { 20 ~ClipboardAndroidTest() override {
18 Clipboard::DestroyClipboardForCurrentThread(); 21 Clipboard::DestroyClipboardForCurrentThread();
19 }; 22 };
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Make sure some text is available 81 // Make sure some text is available
79 EXPECT_TRUE(clipboard().IsFormatAvailable( 82 EXPECT_TRUE(clipboard().IsFormatAvailable(
80 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE)); 83 Clipboard::GetPlainTextWFormatType(), CLIPBOARD_TYPE_COPY_PASTE));
81 84
82 // Make sure the text is what we inserted while simulating the other app 85 // Make sure the text is what we inserted while simulating the other app
83 std::string contents; 86 std::string contents;
84 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents); 87 clipboard().ReadAsciiText(CLIPBOARD_TYPE_COPY_PASTE, &contents);
85 EXPECT_EQ(contents, new_value); 88 EXPECT_EQ(contents, new_value);
86 } 89 }
87 90
91 TEST_F(ClipboardAndroidTest, LastModifiedTimePersists) {
92 // 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
93 // 1. Create a TestingPrefServiceSimple (which is a PrefService)
94 // and also use is registry() function.
95 // 2. Call ClipboardAndroid::RegisterPrefs()
96 // 3. Call ClipboardAndroid::SetLocalState()
97
98 base::Time test_start_time = base::Time::Now();
99 std::string url = "http://example.com/";
100 clipboard().WriteText(url.data(), url.length());
101 base::TimeDelta last_modified_time = clipboard().GetLastModifiedTime();
102 // It's possible the WriteText() took some time, so allow a little slop
103 // (5 seconds) in this comparison; don't check for equality.
104 EXPECT_GE(last_modified_time, test_start_time);
105 EXPECT_LE(last_modified_time,
106 test_start_time + base::TimeDelta::FromSeconds(5));
107
108 // *** Force writing the prefs / storing them, if necessary.
109
110 // Destroy the clipboard and make sure the information persists. (It's be
111 // implicitly recreated when accessed.)
112 Clipboard::DestroyClipboardForCurrentThread();
113
114 // ***
115 // Check that the last modified time hasn't changed from the last time
116 // 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.
117 }
118
88 } // namespace ui 119 } // namespace ui
89 120
90 #include "ui/base/clipboard/clipboard_test_template.h" 121 #include "ui/base/clipboard/clipboard_test_template.h"
OLDNEW
« ui/base/clipboard/clipboard_android.cc ('K') | « ui/base/clipboard/clipboard_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698