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

Unified Diff: ui/android/junit/src/org/chromium/ui/base/ClipboardTest.java

Issue 2824593002: Add ClipboardTest.java back (Closed)
Patch Set: add info Created 3 years, 8 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 | « ui/android/java/src/org/chromium/ui/base/Clipboard.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/junit/src/org/chromium/ui/base/ClipboardTest.java
diff --git a/ui/android/junit/src/org/chromium/ui/base/ClipboardTest.java b/ui/android/junit/src/org/chromium/ui/base/ClipboardTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..3a99aeb9425bf1f808009a80647fcd0390166e7e
--- /dev/null
+++ b/ui/android/junit/src/org/chromium/ui/base/ClipboardTest.java
@@ -0,0 +1,59 @@
+// Copyright 2017 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.
+
+package org.chromium.ui.base;
+
+import android.content.ClipData;
+import android.content.Intent;
+import android.text.SpannableString;
+import android.text.style.RelativeSizeSpan;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import org.chromium.base.ContextUtils;
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+
+/**
+ * Tests logic in the Clipboard class.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class ClipboardTest {
+ private static final String PLAIN_TEXT = "plain";
+ private static final String HTML_TEXT = "<span style=\"color: red;\">HTML</span>";
+
+ @Test
+ public void testClipDataToHtmlText() {
+ ContextUtils.initApplicationContextForTests(RuntimeEnvironment.application);
+ Clipboard clipboard = Clipboard.getInstance();
+
+ // HTML text
+ ClipData html = ClipData.newHtmlText("html", PLAIN_TEXT, HTML_TEXT);
+ assertEquals(HTML_TEXT, clipboard.clipDataToHtmlText(html));
+
+ // Plain text without span
+ ClipData plainTextNoSpan = ClipData.newPlainText("plain", PLAIN_TEXT);
+ assertNull(clipboard.clipDataToHtmlText(plainTextNoSpan));
+
+ // Plain text with span
+ SpannableString spanned = new SpannableString(PLAIN_TEXT);
+ spanned.setSpan(new RelativeSizeSpan(2f), 0, 5, 0);
+ ClipData plainTextSpan = ClipData.newPlainText("plain", spanned);
+ assertNotNull(clipboard.clipDataToHtmlText(plainTextSpan));
+
+ // Intent
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.setType("*/*");
+ ClipData intentClip = ClipData.newIntent("intent", intent);
+ assertNull(clipboard.clipDataToHtmlText(intentClip));
+ }
+}
« no previous file with comments | « ui/android/java/src/org/chromium/ui/base/Clipboard.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698