Chromium Code Reviews| 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.chrome.browser.contextmenu; | 5 package org.chromium.chrome.browser.contextmenu; |
| 6 | 6 |
| 7 import android.content.ClipData; | 7 import android.content.ClipData; |
| 8 import android.content.ClipboardManager; | 8 import android.content.ClipboardManager; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.os.Build; | 10 import android.os.Build; |
| 11 import android.test.FlakyTest; | 11 import android.test.FlakyTest; |
| 12 import android.test.suitebuilder.annotation.MediumTest; | |
| 12 import android.view.ContextMenu; | 13 import android.view.ContextMenu; |
| 13 | 14 |
| 14 import junit.framework.Assert; | 15 import junit.framework.Assert; |
| 15 | 16 |
| 16 import org.chromium.base.test.util.Feature; | 17 import org.chromium.base.test.util.Feature; |
| 17 import org.chromium.chrome.R; | 18 import org.chromium.chrome.R; |
| 18 import org.chromium.chrome.browser.Tab; | 19 import org.chromium.chrome.browser.Tab; |
| 19 import org.chromium.chrome.shell.ChromeShellTestBase; | 20 import org.chromium.chrome.shell.ChromeShellTestBase; |
| 20 import org.chromium.chrome.test.util.TestHttpServerClient; | 21 import org.chromium.chrome.test.util.TestHttpServerClient; |
| 21 import org.chromium.chrome.test.util.browser.contextmenu.ContextMenuUtils; | 22 import org.chromium.chrome.test.util.browser.contextmenu.ContextMenuUtils; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 | 203 |
| 203 Assert.assertTrue("Activity did not regain focus.", | 204 Assert.assertTrue("Activity did not regain focus.", |
| 204 CriteriaHelper.pollForCriteria(new Criteria() { | 205 CriteriaHelper.pollForCriteria(new Criteria() { |
| 205 @Override | 206 @Override |
| 206 public boolean isSatisfied() { | 207 public boolean isSatisfied() { |
| 207 return getActivity().hasWindowFocus(); | 208 return getActivity().hasWindowFocus(); |
| 208 } | 209 } |
| 209 })); | 210 })); |
| 210 } | 211 } |
| 211 | 212 |
| 213 @MediumTest | |
|
Bernhard Bauer
2014/09/30 08:51:08
Why are these tests medium if e.g. testCopyLinkTex
ankit
2014/09/30 09:20:46
I tried running these test cases with @MediumTest
Bernhard Bauer
2014/09/30 10:05:25
Okay, let's try @MediumTest, but can you also chan
| |
| 214 @Feature({"Browser"}) | |
| 215 public void testCopyImageURL() throws InterruptedException, TimeoutException { | |
| 216 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return; | |
|
Bernhard Bauer
2014/09/30 08:51:08
What do we need this check for?
ankit
2014/09/30 09:20:46
Not required.
| |
| 217 | |
| 218 Tab tab = getActivity().getActiveTab(); | |
| 219 ContextMenuUtils.selectContextMenuItem(this, tab, "testImage", | |
| 220 R.id.contextmenu_copy_image_url); | |
| 221 | |
| 222 String expectedUrl = TestHttpServerClient.getUrl( | |
| 223 "chrome/test/data/android/contextmenu/test_image.png"); | |
| 224 | |
| 225 assertEquals("Clipboard text is not correct", expectedUrl, getClipboardT ext()); | |
| 226 } | |
| 227 | |
| 228 @MediumTest | |
| 229 @Feature({"Browser"}) | |
| 230 public void testCopyEmailAddress() throws InterruptedException, TimeoutExcep tion { | |
| 231 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return; | |
| 232 | |
| 233 Tab tab = getActivity().getActiveTab(); | |
| 234 ContextMenuUtils.selectContextMenuItem(this, tab, "testEmail", | |
| 235 R.id.contextmenu_copy_email_address); | |
| 236 | |
| 237 assertEquals("Clipboard text is not correct", "someone@example.com", get ClipboardText()); | |
| 238 } | |
| 239 | |
| 212 private String getClipboardText() { | 240 private String getClipboardText() { |
| 213 ClipboardManager clipMgr = | 241 ClipboardManager clipMgr = |
| 214 (ClipboardManager) getActivity().getSystemService(Context.CLIPBO ARD_SERVICE); | 242 (ClipboardManager) getActivity().getSystemService(Context.CLIPBO ARD_SERVICE); |
| 215 ClipData clipData = clipMgr.getPrimaryClip(); | 243 ClipData clipData = clipMgr.getPrimaryClip(); |
| 216 assertNotNull("Primary clip is null", clipData); | 244 assertNotNull("Primary clip is null", clipData); |
| 217 assertTrue("Primary clip contains no items.", clipData.getItemCount() > 0); | 245 assertTrue("Primary clip contains no items.", clipData.getItemCount() > 0); |
| 218 return clipData.getItemAt(0).getText().toString(); | 246 return clipData.getItemAt(0).getText().toString(); |
| 219 } | 247 } |
| 220 | 248 |
| 221 private void assertStringContains(String subString, String superString) { | 249 private void assertStringContains(String subString, String superString) { |
| 222 assertTrue("String '" + superString + "' does not contain '" + subString + "'", | 250 assertTrue("String '" + superString + "' does not contain '" + subString + "'", |
| 223 superString.contains(subString)); | 251 superString.contains(subString)); |
| 224 } | 252 } |
| 225 } | 253 } |
| OLD | NEW |