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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/ClipboardTest.java

Issue 141533006: [Android] Move the java content/ package to content_public/ to start the split. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small fixes and findbugs line update 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
Index: content/public/android/javatests/src/org/chromium/content/browser/ClipboardTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ClipboardTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ClipboardTest.java
deleted file mode 100644
index 6c9e0b98bc545f45924adb307c252f07e4d6c3b3..0000000000000000000000000000000000000000
--- a/content/public/android/javatests/src/org/chromium/content/browser/ClipboardTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 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.
-
-package org.chromium.content.browser;
-
-import android.content.ClipData;
-import android.content.ClipboardManager;
-import android.content.Context;
-import android.os.Build;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.text.TextUtils;
-
-import org.chromium.base.ThreadUtils;
-import org.chromium.base.test.util.Feature;
-import org.chromium.base.test.util.UrlUtils;
-import org.chromium.content.browser.input.ImeAdapter;
-import org.chromium.content.browser.test.util.Criteria;
-import org.chromium.content.browser.test.util.CriteriaHelper;
-import org.chromium.content_shell_apk.ContentShellTestBase;
-
-import java.util.concurrent.Callable;
-
-public class ClipboardTest extends ContentShellTestBase {
- private static final String TEST_PAGE_DATA_URL = UrlUtils.encodeHtmlDataUri(
- "<html><body>Hello, <a href=\"http://www.example.com/\">world</a>, how <b> " +
- "Chromium</b> doing today?</body></html>");
-
- private static final String EXPECTED_TEXT_RESULT = "Hello, world, how Chromium doing today?";
-
- // String to search for in the HTML representation on the clipboard.
- private static final String EXPECTED_HTML_NEEDLE = "http://www.example.com/";
-
- /**
- * Tests that copying document fragments will put at least a plain-text representation
- * of the contents on the clipboard. For Android JellyBean and higher, we also expect
- * the HTML representation of the fragment to be available.
- */
- @LargeTest
- @Feature({"Clipboard","TextInput"})
- public void testCopyDocumentFragment() throws Throwable {
- launchContentShellWithUrl(TEST_PAGE_DATA_URL);
- assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading());
-
- final ClipboardManager clipboardManager = (ClipboardManager)
- getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
- assertNotNull(clipboardManager);
-
- // Clear the clipboard to make sure we start with a clean state.
- clipboardManager.setPrimaryClip(ClipData.newPlainText(null, ""));
- assertFalse(hasPrimaryClip(clipboardManager));
-
- getImeAdapter().selectAll();
- getImeAdapter().copy();
-
- // Waits until data has been made available on the Android clipboard.
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- return hasPrimaryClip(clipboardManager);
- }
- });
- }
- }));
-
- // Verify that the data on the clipboard is what we expect it to be. For Android JB MR2
- // and higher we expect HTML content, for other versions the plain-text representation.
- final ClipData clip = clipboardManager.getPrimaryClip();
- assertEquals(EXPECTED_TEXT_RESULT, clip.getItemAt(0).coerceToText(getActivity()));
-
- // Android JellyBean and higher should have a HTML representation on the clipboard as well.
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- String htmlText = clip.getItemAt(0).getHtmlText();
-
- assertNotNull(htmlText);
- assertTrue(htmlText.contains(EXPECTED_HTML_NEEDLE));
- }
- }
-
- private ImeAdapter getImeAdapter() {
- return getContentViewCore().getImeAdapterForTest();
- }
-
- // Returns whether there is a primary clip with content on the current clipboard.
- private Boolean hasPrimaryClip(ClipboardManager clipboardManager) {
- final ClipData clip = clipboardManager.getPrimaryClip();
- if (clip != null && clip.getItemCount() > 0) {
- return !TextUtils.isEmpty(clip.getItemAt(0).getText());
- }
-
- return false;
- }
-}

Powered by Google App Engine
This is Rietveld 408576698