| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.content.ClipData; | 8 import android.content.ClipData; |
| 9 import android.content.ClipboardManager; | 9 import android.content.ClipboardManager; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); | 42 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Tests that copying document fragments will put at least a plain-text repr
esentation | 46 * Tests that copying document fragments will put at least a plain-text repr
esentation |
| 47 * of the contents on the clipboard. For Android JellyBean and higher, we al
so expect | 47 * of the contents on the clipboard. For Android JellyBean and higher, we al
so expect |
| 48 * the HTML representation of the fragment to be available. | 48 * the HTML representation of the fragment to be available. |
| 49 */ | 49 */ |
| 50 @LargeTest | 50 @LargeTest |
| 51 @TargetApi(Build.VERSION_CODES.JELLY_BEAN) | 51 @TargetApi(Build.VERSION_CODES.JELLY_BEAN) |
| 52 @Feature({"Clipboard","TextInput"}) | 52 @Feature({"Clipboard", "TextInput"}) |
| 53 @RerunWithUpdatedContainerView | 53 @RerunWithUpdatedContainerView |
| 54 public void testCopyDocumentFragment() throws Throwable { | 54 public void testCopyDocumentFragment() throws Throwable { |
| 55 final ClipboardManager clipboardManager = (ClipboardManager) | 55 final ClipboardManager clipboardManager = (ClipboardManager) |
| 56 getActivity().getSystemService(Context.CLIPBOARD_SERVICE); | 56 getActivity().getSystemService(Context.CLIPBOARD_SERVICE); |
| 57 assertNotNull(clipboardManager); | 57 assertNotNull(clipboardManager); |
| 58 | 58 |
| 59 // Clear the clipboard to make sure we start with a clean state. | 59 // Clear the clipboard to make sure we start with a clean state. |
| 60 clipboardManager.setPrimaryClip(ClipData.newPlainText(null, "")); | 60 clipboardManager.setPrimaryClip(ClipData.newPlainText(null, "")); |
| 61 assertFalse(hasPrimaryClip(clipboardManager)); | 61 assertFalse(hasPrimaryClip(clipboardManager)); |
| 62 | 62 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // Returns whether there is a primary clip with content on the current clipb
oard. | 112 // Returns whether there is a primary clip with content on the current clipb
oard. |
| 113 private Boolean hasPrimaryClip(ClipboardManager clipboardManager) { | 113 private Boolean hasPrimaryClip(ClipboardManager clipboardManager) { |
| 114 final ClipData clip = clipboardManager.getPrimaryClip(); | 114 final ClipData clip = clipboardManager.getPrimaryClip(); |
| 115 if (clip != null && clip.getItemCount() > 0) { | 115 if (clip != null && clip.getItemCount() > 0) { |
| 116 return !TextUtils.isEmpty(clip.getItemAt(0).getText()); | 116 return !TextUtils.isEmpty(clip.getItemAt(0).getText()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 return false; | 119 return false; |
| 120 } | 120 } |
| 121 } | 121 } |
| OLD | NEW |